开发者

Rounding decimal in sql server

开发者 https://www.devze.com 2023-02-14 20:43 出处:网络
Is it possible to round downward with SQL server 2008? E.g. .96855 is roun开发者_JAVA技巧ded to .968.

Is it possible to round downward with SQL server 2008? E.g. .96855 is roun开发者_JAVA技巧ded to .968.

I.e. up to .96899 I want to round .96899 by avoiding rest.


SELECT round(0.96855, 3, 1)

-> 0.96800

For 0.968 : cast(round(0.96855, 3, 1) as decimal(10,3)) works fine.

Ref: Round (if last param to Round is anything other than zero, it truncates)


cast(round(0.96855, 3, 1) as decimal(10,3))


Could this help?

SELECT ROUND(123.9994, 3)    
Results: 123.9990  


SELECT ROUND(123.9995, 3)    
Results: 124.0000   
0

精彩评论

暂无评论...
验证码 换一张
取 消