Re: ORDER BY CASE ... - Mailing list pgsql-sql

From Reinoud van Leeuwen
Subject Re: ORDER BY CASE ...
Date
Msg-id 20060213154024.GJ46853@spoetnik.xs4all.nl
Whole thread Raw
In response to ORDER BY CASE ...  (Mario Splivalo <mario.splivalo@mobart.hr>)
List 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.v@n.leeuwen.net
http://www.xs4all.nl/~reinoud
__________________________________________________


pgsql-sql by date:

Previous
From: Mario Splivalo
Date:
Subject: Re: ORDER BY CASE ...
Next
From: Mathieu Arnold
Date:
Subject: Re: ORDER BY CASE ...