0

我有我写的这个 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 查询中我可能做错了什么。

4

1 回答 1

4

这里有很多语法错误。

尝试 :

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
于 2013-01-16T16:16:02.947 回答