Quantcast
Channel: Rob Bamforth's Blog
Viewing all articles
Browse latest Browse all 35

SQL – How to round a float to 2 (or any) decimal places

$
0
0

You can use the str() function to trim a float value to X number of places:

STR ( float_expression [ , length [ , decimal ] ] )

Example for a Total of 7 characters with 2 to the right of the decimal point:
select str(12345.6789, 7, 2)

Result:
12345.68

 



Viewing all articles
Browse latest Browse all 35

Trending Articles