From: Gregory Stark <stark@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: A. Kretschmer <andreas.kretschmer@schollglas.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Sql ORDER BY and ASC/DESC question
Date: Wed, 30 Jan 2008 20:24:09 +0000
Message-ID: <87ir1buknq.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <14687.1201716029@sss.pgh.pa.us>
References: <aa457f86948348248e93c6fc38b4b1f6@pobox.sk>
<20080130104226.GF26490@a-kretschmer.de>
<87tzkvbfr6.fsf@oxford.xeocode.com>
<14687.1201716029@sss.pgh.pa.us>
"Tom Lane" <tgl@sss.pgh.pa.us> writes:
> Gregory Stark <stark@enterprisedb.com> writes:
>
>> ORDER BY
>> CASE ?
>> WHEN 1 THEN name ASC
>
> Uh, no, putting the ASC/DESC decoration inside a CASE like that is not
> gonna work
doh! I had a feeling something was wrong but couldn't put my finger on it
before I hit send. Sigh.
> For numerical sort keys you can cheat by using "-x" in place of
> "x DESC", but I'm not aware of any equivalent hack for text keys.
Yeah, you could do a really kludgy thing with a second sort expression where
you null out one expression or the other depending on the parameter but it
starts to look more and more spaghetti-like.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!
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: stark@enterprisedb.com, tgl@sss.pgh.pa.us, andreas.kretschmer@schollglas.com
Subject: Re: Sql ORDER BY and ASC/DESC question
In-Reply-To: <87ir1buknq.fsf@oxford.xeocode.com>
* 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