Re: SQL Question - Mailing list pgsql-general

From Tom Lane
Subject Re: SQL Question
Date
Msg-id 29756.984082434@sss.pgh.pa.us
Whole thread Raw
In response to SQL Question  (Matthew <matt@ctlno.com>)
List pgsql-general
Matthew <matt@ctlno.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

pgsql-general by date:

Previous
From: "Roderick A. Anderson"
Date:
Subject: Re: Update through views?
Next
From: Tom Lane
Date:
Subject: Re: inheritance and primary/foreign keys