Skip to content
Advertisement

SQL Server: round decimal number and convert to int (within Select)

I am using the following line within a Select which returns a number with decimals, e.g. 33.33333.

How can I round this within the Select and convert to integers so that I don’t have decimals, e.g. in the above example it should return 33 ?

Advertisement

Answer

You can use ROUND function to round the value to integer:

This will retain the type, e.g rounded float will stay float. If you also need to return int data type (or other integer data types), you need to also convert it:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement