Thread: Regarding decode function

Regarding decode function

From
Buchi_Babu@cymer.com
Date:
<br /><font face="Arial" size="2">Hi All,</font><br /><font face="Times New Roman" size="3"> </font><br /><font
face="Arial"size="2">Right now I have a query which uses decode function to get data in Oracle database, I want know is
thereany alternative function to decode which can do the decode functionality in Postgresql.</font><br /><font
face="TimesNew Roman" size="3"> </font><br /><font face="Arial" size="2">Thanks in advance for your great
help.</font><br/><font face="Times New Roman" size="3"> </font><br /><font face="Arial" size="2">Thanks</font><br
/><fontface="Arial" size="2">Babu Mannem</font><font face="Times New Roman" size="3"> </font><br /><font face="Times
NewRoman" size="3"> </font> 

Re: Regarding decode function

From
Doris Bernloehr
Date:
> Right now I have a query which uses decode function to get data in 
> Oracle database, I want know is there any alternative function to 
> decode which can do the decode functionality in Postgresql.

Oracle: decode (value, 0, 'zero', 1, 'one', 'unknown')

In PostgreSQL you have to use CASE WHEN Syntax:

ANSI: CASE WHEN value=0 THEN 'zero' WHEN value=1 THEN 'one' ELSE 
'unknown' END

or

CASE value WHEN 0 THEN 'zero' WHEN 1 THEN 'one' ELSE 'unknown' END

Regards
Doris