| От | Martijn van Oosterhout |
|---|---|
| Тема | Re: CASE in ORDER BY clause |
| Дата | |
| Msg-id | 20070707191856.GD18623@svana.org обсуждение |
| Ответ на | Re: CASE in ORDER BY clause (Perry Smith <pedz@easesoftware.com>) |
| Список | pgsql-general |
On Sat, Jul 07, 2007 at 01:49:09PM -0500, Perry Smith wrote: > >># select start_date from show_date > >># order by > >># case when start_date > CURRENT_DATE then start_date end desc, > >># case when start_date <= CURRENT_DATE then start_date end asc; > >> > I am very novice, but that looks odd to me. I would have expected > the asc or desc keywords need to go inside the case (before the > end). Otherwise you have either: The keyword asc/desc applies to an expression, the result is not an expression, hence you cannot put the asc/desc inside a case. > ... order by start_date desc, asc; > or > ... order by desc, start_date asc; Almost, it's actually: ... order by start_date desc, null asc; or ... order by null desc, start_date asc; Ordering by a constant has no effect, which is why it works. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to litigate.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера