Re: Regarding decode function

From: Doris Bernloehr <bedo7(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Regarding decode function
Date: 2003-10-04 00:50:14
Message-ID: 3F7E1946.3060604@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-10-04 09:56:38 Running tally
Previous Message Wei Weng 2003-10-03 22:34:41 function with variable length of parameters