How to convert float to int using round method in ms sql?

I tried using

select ROUND(1235.53)
--(It can contain "n" digit of scale)

But there was an error

The round function requires 2 to 3 arguments.

I am not sure what the use of other parameters is.

+4
source share
2 answers

Better to use CAST INT / CEILING / FLOOR :

SELECT CEILING(1235.53)
SELECT FLOOR(1235.53)
SELECT CAST(1235.53 AS INT)

CEILING : assigns you the upper value of integers

enter image description here

FLOOR : gives a lower integer value

enter image description here

+5
source

Set decimal values ​​to zero

select cast(ROUND(1235.53,0) as int)  Returns 1236

select cast(1235.53 as int)           Returns 1235
+2
source

Source: https://habr.com/ru/post/1655201/


All Articles