Re: ORDER BY CASE ...

Поиск
Список
Период
Сортировка
От Reinoud van Leeuwen
Тема Re: ORDER BY CASE ...
Дата
Msg-id 20060213154024.GJ46853@spoetnik.xs4all.nl
обсуждение исходный текст
Ответ на ORDER BY CASE ...  (Mario Splivalo <mario.splivalo@mobart.hr>)
Список 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 по дате отправления:

Предыдущее
От: Mario Splivalo
Дата:
Сообщение: Re: ORDER BY CASE ...
Следующее
От: Mathieu Arnold
Дата:
Сообщение: Re: ORDER BY CASE ...