From: Tom Haddon <tom@betterhealthfoundation.org>
To: pgsql-sql@postgresql.org
Subject: Case Statement
Date: Wed, 31 Jul 2002 15:59:37 -0700
Message-ID: <NEBBIHDGCLBEJMPFAMLAGEKCCHAA.tom@betterhealthfoundation.org> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tom@betterhealthfoundation.org
Subject: Re: Case Statement
In-Reply-To: <NEBBIHDGCLBEJMPFAMLAGEKCCHAA.tom@betterhealthfoundation.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox