Re: Funny date-sorting task

Поиск
Список
Период
Сортировка
От Frank Bax
Тема Re: Funny date-sorting task
Дата
Msg-id 5.2.1.1.0.20070512231137.042f88d0@pop6.sympatico.ca
обсуждение исходный текст
Ответ на Funny date-sorting task  (Andreas <maps.on@gmx.net>)
Ответы Re: Funny date-sorting task  ("Rodrigo De León" <rdeleonp@gmail.com>)
Список pgsql-sql
At 07:40 PM 5/12/07, Andreas wrote:
>I've got a stack of tasks to show in a list.
>Every task has a timestamp  X  that may be NULL or a date. It contains the 
>date when this tasks should be done.
>Sometimes it has date and the time-part, too.
>
>
>The list should be like this:
>1)   X  sometime today should come first in ascending time order.
>2)   X  in the past should show up after (1) in descending order so that 
>not so long back dates come first
>3)   X  =  NULL
>4)   X sometime in the future
>
>Could you provide a clever solution?


ORDER BY CASE WHEN X=today THEN 1 ELSE
CASE WHEN X<today THEN 2 ELSE
CASE WHEN X IS NULL THEN 3 ELSE
CASE WHEN X>today THEN 4 ELSE 5 END END END END



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

Предыдущее
От: Andreas
Дата:
Сообщение: Funny date-sorting task
Следующее
От: "Rodrigo De León"
Дата:
Сообщение: Re: Funny date-sorting task