Categories
Database Development

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 […]

Categories
Database Development

query output shows ##,###,### instead of right output

I am working on one project in which, query output gives ##,###,### instead of right values. according to requirement we calculate the time period and display it in separate table. this is query I am using as calculation select (to_char((coalesce(11808000,0) – (coalesce(3562.66,0) – (coalesce(1800,0) + (coalesce(1800,0))))),’FM99,999,999′))::character varying as mytest so if I run this one, […]

Categories
Database Development

How to validate with 0 if values not available in column?

I am newbie in postgresql, Currently I am working on one project, my query works fine when values are available in column, but if values are not there I want to use 0 instead of it. How can we write validation in my query, can any one help me to solve this ? select (to_char((myfirsthour) […]

Categories
Database Development

Postgresql values not inserting

Hi I am trying to add following values to my table, but it gives following error, ERROR: syntax error at or near "::" LINE 1: …tion))/nullif((s_totalnorevws),0),’FM99,999,999′))::characte… insert into testschema.tbls values (212,to_char(((s_sumdduration))/nullif((s_totalnorevws),0),’FM99,999,999′))::character varying as ob_arht);

Categories
Database Development

Syntax error in query

I am using postgresql and I am getting syntax error in one of my query related to calculation. I also checked in online website validated it, but still it shows same. can anyone help me to solve this issue? (to_char(round(s_ib_handling_time)/nullif(s_handled),0), 2),’FM99,999,999′))::character varying as aht