Reputation: 3027
I have this sql statement that i have written. this sql statement i am trying to write is in postgres. I have the same sql statement in oracle and it works ok. I have read through the syntax but its looks fine to me. The oracle sql statement looks like this:
select to_char(calldate,'Day') as Day,
trunc(calldate) as transdate,
decode(zoneorange,'-1, 'Onnet','0','Orange Uganda','1','UTL','2','MTN',3,'Airtel','4','Warid','5','MTN Fixed','Undefined') as destination
The postgres sql statement i have written looks like this:
select to_char(calldate,'Day') as Day,
date_trunc('day',calldate) as transdate,
(case when zoneorange = '-1'
then 'Onnet'::text = '0'
then 'Orange Uganda' = '1'
then 'UTL' = '2'
then 'MTN' =3
then 'Airtel' = '4'
then 'Warid' = '5',
then 'MTN Fixed'
else 'Undefined' end) as destination
It complains of the syntax error in my case statement. It looks ok to me so i dont know whats wrong. What could i be doing wrong in my postgresql query.
Upvotes: 0
Views: 2809
Reputation: 16351
A lot of syntax errors here.
Try :
select to_char(calldate,'Day') as Day,
date_trunc('day',calldate) as transdate,
(case zoneorange when '-1' then 'Onnet'
when '0' then 'Orange Uganda'
when '1' then 'UTL'
when '2' then 'MTN'
when '3' then 'Airtel'
when '4' then 'Warid'
when '5' then 'MTN Fixed'
else 'Undefined' end) as destination
Upvotes: 4