使用十进制舍入问题

时间:2013-08-23 12:16:28

标签: sql decimal

SELECT CAST(960 AS NUMERIC(18,2)) -- it gives 960.00 
SELECT CAST(178.5 AS NUMERIC(18,2)) -- it gives 178.50

我需要结果960和178.5,我怎么能这样做

1 个答案:

答案 0 :(得分:0)

使用以下

SELECT CAST(960 AS NUMERIC(18,0)) -- it will give 960

SELECT CAST(178.5 AS NUMERIC(18,1)) -- it will give 178.5