Re: how to return field based on field= NULL or not

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: how to return field based on field= NULL or not
Date: 2009-08-24 11:26:02
Message-ID: 20090824112602.GI5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 24, 2009 at 12:54:31PM +0200, Alban Hertroys wrote:
> CASE
> WHEN fieldA IS NOT NULL THEN fieldA
> WHEN fieldB IS NOT NULL THEN fieldB
> WHEN fieldC IS NOT NULL THEN fieldC
> ELSE fieldD
> END

BTW, the above expression is identical to:

COALESCE(fieldA,fieldB,fieldC,fieldD)

--
Sam http://samason.me.uk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2009-08-24 12:02:34 Re: Multiple table entries?
Previous Message Alban Hertroys 2009-08-24 10:54:31 Re: how to return field based on field= NULL or not