CEILING, FLOOR, ROUND FUNCTION IN SQL TO ROUND UP NEAREST WHOLE NUMBER



--CEILING ROUND TO UP
SELECT CEILING(2.3) ---------Round to 3                                         

SELECT CEILING(2.6) ---------Round to 3 


--FLOOR ROUND TO DOWN
SELECT FLOOR(2.9) -----------Round to 2
SELECT FLOOR(2.4) -----------Round to 2

----What I need is 2.6 rounds up to 3. Also 2.4 rounds to 2.
SELECT ROUND(yourvalue,0)
SELECT ROUND(2.6,0)----------Round to 3
SELECT ROUND(2.4,0)----------Round to 2

No comments:

Post a comment