From: | Perry Smith <pedz(at)easesoftware(dot)com> |
---|---|
To: | Gregory Stark <stark(at)enterprisedb(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: CASE in ORDER BY clause |
Date: | 2007-07-07 18:49:09 |
Message-ID: | 94BEBE52-8D5D-48D5-AF58-7FC579A4DDC3@easesoftware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On Fri, Jul 06, 2007 at 08:02:54PM +0400, Viatcheslav Kalinin wrote:
>>
>> # select start_date from show_date
>> # order by
>> # case when start_date > CURRENT_DATE then start_date end desc,
>> # case when start_date <= CURRENT_DATE then start_date end asc;
>>
I am very novice, but that looks odd to me. I would have expected
the asc or desc keywords need to go inside the case (before the
end). Otherwise you have either:
... order by start_date desc, asc;
or
... order by desc, start_date asc;
This is what I would expect the syntax to be:
# select start_date from show_date
# order by
# case when start_date > CURRENT_DATE then start_date desc end,
# case when start_date <= CURRENT_DATE then start_date asc end;
Or, it seems like you could do:
# select start_date from show_date
# order by start_date
# case when start_date > CURRENT_DATE then desc end,
# case when start_date <= CURRENT_DATE then asc end;
From | Date | Subject | |
---|---|---|---|
Next Message | Carmen Martinez | 2007-07-07 19:06:02 | catalog location |
Previous Message | Chris Travers | 2007-07-07 16:25:52 | Arrays of records? |