Re: sql question - Mailing list pgsql-general

From Ross J. Reedstrom
Subject Re: sql question
Date
Msg-id 20000712182535.A6848@rice.edu
Whole thread Raw
In response to sql question  (Travis Bauer <trbauer@indiana.edu>)
Responses Re: sql question  (Travis Bauer <trbauer@indiana.edu>)
List pgsql-general
On Wed, Jul 12, 2000 at 05:33:09PM -0500, Travis Bauer wrote:
>
> Let's say I have a table t1 with two fields, x and y.  How do I write an
> sql statement like:
>
> select x if y>1 else 0 from t1;

SELECT CASE WHEN y>1 THEN x ELSE 0 END FROM t1;

From page 33 of Bruce's book, at:

http://www.postgresql.org/docs/aw_pgsql_book/node52.html

Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re: [NOVICE] newbie problem on creating table
Next
From: Richard Harvey Chapman
Date:
Subject: Re: Triggers with arguments