在Netezza中,此表达式自动舍入结果,我该如何避免?我需要保持原始计算值1.5,而不是1
select cast ( (4 -1) / 2 AS NUMERIC (15,6)) as result --> gives 1.0000..
答案 0 :(得分:1)
将一个参数更改为NUMERIC
以避免整数除法
SELECT (4 -1) / 2.0 AS result
或:
SELECT (4-1) / CAST(2 AS NUMERIC(15,6)) AS result
司:
1 / 10 -> 0
1.0 / 10 -> 0.1
1 / 10.0 -> 0.1
1.0/10.0 -> 0.1