简体   繁体   English

SQL Server 2014舍入函数

[英]SQL Server 2014 Round Function

I'm using SQL Server 2014 and I read this MSDN page for ROUND function: ROUND (Transact-SQL) 我正在使用SQL Server 2014,并且已阅读此MSDN页面的ROUND函数: ROUND(Transact-SQL)

When I run this example from above page, the result of my is not same as MSDN result: 当我从上一页运行此示例时,my的结果与MSDN的结果不同:

MSDN: MSDN:

SELECT ROUND(123.4545, 2)  -->  123.45 

My result: 我的结果:

 SELECT ROUND(123.4545, 2)  -->  123.4500

There are two extra zeros in my result. 我的结果中有两个额外的零。 Where is the problem? 问题出在哪儿? I want to have MSDN result. 我想要MSDN结果。

Thanks 谢谢

You have given 4 decimals so you would get results in 4 decimals. 您给了4个小数,因此您将获得4个小数的结果。

Try like this, 这样尝试

SELECT convert(DECIMAL(8, 2), ROUND(123.4545, 2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM