Case Statement

From: "Tom Haddon" <tom(at)betterhealthfoundation(dot)org>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Case Statement
Date: 2002-07-31 22:59:37
Message-ID: NEBBIHDGCLBEJMPFAMLAGEKCCHAA.tom@betterhealthfoundation.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Folks,

Pretty basic one here. I'm trying to do a SELECT statement that includes a
CASE structure that will be used in the ORDER BY clause, and I want the CASE
structure to evaluate a bunch of criteria and in each case increment its
value by a certain amount:

SELECT id, description CASE
field1 IS TRUE THEN CASE=CASE+1
field2 IS TRUE THEN CASE=CASE+2
END
FROM table
ORDER BY CASE, description;

Am I misunderstanding what CASE can do here, and if so, how else do I do
what I'm trying to do? I know that that isn't right - any pointers
appreciated.

Thanks, Tom

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2002-07-31 23:17:04 Re: Case Statement
Previous Message Stephan Szabo 2002-07-31 20:08:43 Re: negative queries puzzle