I want to round the value from 1572.750000 to 1572.75
SELECT ROUND(1572.750000, 2)
I tried above format, but it was not working. Please any one help me out.
I think the simplest way is to convert to decimal
:
select cast(1572.750000 as decimal(10, 2))
If you want a string output, you can use the str()
function (documented here ).
The confusion occurs because round()
changes the value , but it does not change the type . Hence, whatever application is using the value can format it as it wants. When the application knows that the value has only two decimal places (with decimal(10, 2)
) or the code converts directly to a string, then this is not an issue.
你可以用这个
SELECT cast(1572.750000 as decimal(15,2))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.