Re: sql question

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: sql question
Date: 2000-07-12 23:25:35
Message-ID: 20000712182535.A6848@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Harvey Chapman 2000-07-12 23:30:24 Re: Triggers with arguments
Previous Message Tom Lane 2000-07-12 23:08:23 Re: Re: [NOVICE] newbie problem on creating table