Re: function DECODE and triggers

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Rafael Montoya <rafo-mm(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: function DECODE and triggers
Date: 2005-10-26 10:22:10
Message-ID: 1130322130.32260.2.camel@braydb.bray-healthcare.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2005-10-25 at 18:31 +0200, Rafael Montoya wrote:
> Thanks for your answer, and if i have many options like
>
> decode (pre.C_EST,'01','U','02','M','03','W','04','D','05','O','06','S','')
> as Est
>
> do i have to write many else options in this way?
>
> select case when pre.C_EST = '01' THEN 'U'
> ELSE when pre-C_EST = '02' THEN 'M'
> ...
> END AS EST
>
> Rafael

The syntax is

CASE WHEN condition1 THEN value1
WHEN condition2 THEN value2
...
ELSE default_value
END

Oliver

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2005-10-26 12:01:01 Re: function DECODE and triggers
Previous Message Andrus 2005-10-26 10:02:22 Re: alt+F not working after calling pg_dump