Wrong output getting from query Hi I have written this query as per my project requirement. But it is generating wrong output.
select (to_char((33)/nullif((17400/3600),0),'FM99,999,999'))::character varying as userdatas

currently it is generating 8 as output. But according to calculation it is different,
= 33/(17400/3600)
= 33/(4.8333333333333)
= 33/4.8333333333333
= 6.8275862068966
It should display 7
Can anyone help me with this issue ?
All your numbers are integers, so the whole expression is done using integer division. You need to either provide numeric constant, e.g. using 3600.0 or cast at least one number to numeric
select 33/(17400/3600::numeric);

returns 6.8276, when applying to_char() it's correctly rounded to 7:
select to_char(33/(17400/3600::numeric),'FM99,999,999')

Online example