Re: order by desc - with zeros on top

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: order by desc - with zeros on top
Дата
Msg-id 54EC22FA-D89C-4CD3-8146-FD4668F21B2A@seespotcode.net
обсуждение исходный текст
Ответ на order by desc - with zeros on top  (Christoph Frick <frick@sc-networks.com>)
Список pgsql-novice
On Jun 14, 2006, at 0:29 , Christoph Frick wrote:

> IIRC there where recently a sql code snippet, that solved the
> problem of
> "ordering a list of ints descending - but keep the zero on top":

SELECT shown_production_id
FROM wherever
ORDER BY shown_production_id = 0
    , shown_production_id desc;

I don't remember if TRUE sorts before FALSE, but either use = 0 or <>
0. That should work.

Michael Glaesemann
grzm seespotcode net




В списке pgsql-novice по дате отправления:

Предыдущее
От: Christoph Frick
Дата:
Сообщение: order by desc - with zeros on top
Следующее
От: chelsea boot
Дата:
Сообщение: Replacing data