我有一条我写的sql语句。我正在尝试编写的这条sql语句是postgres。我在oracle中有相同的sql语句,它工作得很好。我已经通读了语法,但它看起来很好。oracle sql语句如下所示:
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
我编写的postgres sql语句如下所示:
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
它会报告我的case语句中的语法错误。在我看来还可以,所以我不知道出了什么问题。我在postgresql查询中可能做错了什么。
发布于 2013-01-17 00:16:03
这里有很多语法错误。
尝试:
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
https://stackoverflow.com/questions/14362770
复制相似问题