Reputation: 898
I'm using SQL-Server 2008 R2.
I need to achieve following rounding. If first digit after decimal point is 0 It should round to lower side, if higher or equal to 1, should round to higher side, sample data:
3.09 ---> 3
3.1 ---> 4
0 ---> 0
3.005 ---> 3
668.15 ---> 669
What would be simplest way to achieve It?
I've tried to do something like that:
SELECT CEILING(3.09) -- this is incorrect, returning 4 instead of 3
SELECT ROUND(3.09,0) -- with 3.09 is ok, but if I'm trying to round 3.1 It still returning 3.00 instead of 4
Maybe somehow could I combine It? Or I need any other function?
Upvotes: 1
Views: 125
Reputation: 9299
SELECT ROUND(val + 0.4, 0) rnd_val
FROM (
VALUES
(3.09),
(3.1 ),
(0),
(3.005),
(668.15)
)v (val)
Upvotes: 4