On Thu, 22 Nov 2001, MindTerm wrote:
> I am writing to ask how to port oracle's decode( ..)
> function to postgresql ?
The ANSI SQL version of decode is CASE.
See http://www.postgresql.org/idocs/index.php?functions-conditional.html
for the full documentation, but basically, it works like this:
Oracle:
decode (value, 0, 'zero', 1, 'one', 'unknown')
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
--
Tod McQuillin