SQL 服务器 2017 小数点四舍五入
SQL Server 2017 decimal rounding
我用过SQL Server 2005
SQL Server 2005 是:
select round(17.404800,2)
结果 17.40
select round(18.522400,2)
结果 18.52
但在 SQL Server 2017 中,结果是:
select round(17.404800,2)
结果 17.400000
select round(18.522400,2)
结果 18.520000
我想在 SQL Server 2017 中显示 SQL Server 2005 结果 (= 17.40 / 18.52) - 我应该怎么做?
我觉得你应该投
像这样-
select cast(round(18.522400,2) as decimal(6,2))
输出-
18.52
使用这个查询
select CAST (17.404800 AS decimal (6,2))
select CAST (18.522400 AS decimal (6,2))
并且如果你需要在施法后四舍五入
SELECT ROUND(CAST (17.404800 AS decimal (18,2)), 2);
select cast(17.404800 as numeric(6,2));
select cast(18.522400 as numeric(6,2))
我用过SQL Server 2005
SQL Server 2005 是:
select round(17.404800,2)
结果 17.40
select round(18.522400,2)
结果 18.52
但在 SQL Server 2017 中,结果是:
select round(17.404800,2)
结果 17.400000
select round(18.522400,2)
结果 18.520000
我想在 SQL Server 2017 中显示 SQL Server 2005 结果 (= 17.40 / 18.52) - 我应该怎么做?
我觉得你应该投
像这样-
select cast(round(18.522400,2) as decimal(6,2))
输出-
18.52
使用这个查询
select CAST (17.404800 AS decimal (6,2))
select CAST (18.522400 AS decimal (6,2))
并且如果你需要在施法后四舍五入
SELECT ROUND(CAST (17.404800 AS decimal (18,2)), 2);
select cast(17.404800 as numeric(6,2)); select cast(18.522400 as numeric(6,2))