From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Sql ORDER BY and ASC/DESC question |
Date: | 2008-01-30 20:24:09 |
Message-ID: | 87ir1buknq.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Gregory Stark <stark(at)enterprisedb(dot)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!
From | Date | Subject | |
---|---|---|---|
Next Message | Luca Clementi | 2008-01-30 23:37:01 | Problem with the to_timestamp function |
Previous Message | Tom Lane | 2008-01-30 18:00:29 | Re: Sql ORDER BY and ASC/DESC question |