Re: IF function? - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: IF function?
Date
Msg-id 46375322.80907@iol.ie
Whole thread Raw
In response to Re: IF function?  (novnov <novnovice@gmail.com>)
List 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@iol.ie
---------------------------------------------------------------

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: dump-restore only one table
Next
From: Michael Glaesemann
Date:
Subject: Re: pgsql and Mac OS X