Reputation: 17107
In Netezza, this expression automatically rounds down the result, how can I avoid that? I need to keep the original calculated value of 1.5, not 1
select cast ( (4 -1) / 2 AS NUMERIC (15,6)) as result --> gives 1.0000..
Upvotes: 1
Views: 5721
Reputation: 176004
Change one of arguments to NUMERIC
to avoid integer division
SELECT (4 -1) / 2.0 AS result
or:
SELECT (4-1) / CAST(2 AS NUMERIC(15,6)) AS result
Division:
1 / 10 -> 0
1.0 / 10 -> 0.1
1 / 10.0 -> 0.1
1.0/10.0 -> 0.1
Upvotes: 2