Re: IF function?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: IF function?
Date: 2007-05-01 14:48:02
Message-ID: 46375322.80907@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/05/2007 15:38, novnov wrote:

> I didn't express myself clearly. Is there an IIF type function one can use
> inline in a view?
>
> SELECT UserName, IIF(mybooleanfield = true, "It's true", "It's not true") as
> SayIt FROM tblUser

That's what CASE is for:

select
case
when mybooleanfield then 'It''s true'
else 'It''s not true'
end as SayIt
from
tblUser;

(...or something like that - look it up in the docs).

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
---------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-05-01 15:03:03 Re: pgsql and Mac OS X
Previous Message Tom Lane 2007-05-01 14:43:37 Re: dump-restore only one table