I'm looking to round values like
2.3913 -> 2.5
4.6667 -> 4.5
2.11 -> 2
How can I manage this in SQL?
Thanks
SQL Server ROUND() Function The ROUND() function rounds a number to a specified number of decimal places.
If you'd like to round a floating-point number to a specific number of decimal places in SQL, use the ROUND function. The first argument of this function is the column whose values you want to round; the second argument is optional and denotes the number of places to which you want to round.
SELECT ROUND(@value, 1); SELECT ROUND(@value, 2); SELECT ROUND(@value, 3); In this example, we can see that with decimal values round up to the nearest value as per the length.
SELECT ROUND(2.2 * 2, 0) / 2
gets you to the nearest .5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With