Re: SQL Question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthew <matt(at)ctlno(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL Question
Date: 2001-03-08 20:13:54
Message-ID: 29756.984082434@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthew <matt(at)ctlno(dot)com> writes:
> What I would like is something like this (using pseudo sql)
> select (if(col1>1) true else if (col1<= 1) false) from foo;

This particular example could be written as just

select col1>1 from foo

since a boolean result is a perfectly good result.

More generally, you could use the CASE construct for conditional
expressions. See
http://www.postgresql.org/devel-corner/docs/postgres/functions-conditional.html

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas F. O'Connell 2001-03-08 20:28:10 infinity
Previous Message Roderick A. Anderson 2001-03-08 19:29:53 Re: Update through views?