From: | Reinoud van Leeuwen <reinoud(dot)v(at)n(dot)leeuwen(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: ORDER BY CASE ... |
Date: | 2006-02-13 15:40:24 |
Message-ID: | 20060213154024.GJ46853@spoetnik.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, Feb 13, 2006 at 04:35:30PM +0100, Mario Splivalo wrote:
> Am I misusing the ORDER BY with CASE, or, what? :)
>
> I have a table, messages, half dozen of columns, exposing here just
> three of them:
>
> pulitzer2=# select id, "from", receiving_time from messages where
> service_id = 20 order by case when 5=5 then 2 else 3 end desc limit 5;
I'm not sure what you are trying to do here, but it seems that an order by
statement should at least contain something that is part of the resultrow.
"case when 5=5 then 2 else 3 end desc limit 5" does not contain any column
to sort on. So I think it will evaluate to some constant value and not
sorting is really done
--
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen reinoud(dot)v(at)n(dot)leeuwen(dot)net
http://www.xs4all.nl/~reinoud
__________________________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Mario Splivalo | 2006-02-13 15:47:48 | Re: ORDER BY CASE ... |
Previous Message | Mathieu Arnold | 2006-02-13 15:39:12 | Re: ORDER BY CASE ... |