Re: Sorting distinct dates by year and month respectively

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Sorting distinct dates by year and month respectively
Дата
Msg-id 29995.1149692180@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Sorting distinct dates by year and month respectively  ("Matt Arnilo S. Baluyos (Mailing Lists)" <matt.baluyos.lists@gmail.com>)
Список pgsql-novice
"Matt Arnilo S. Baluyos (Mailing Lists)" <matt.baluyos.lists@gmail.com> writes:
> ... ORDER BY date_part('year', article_pubdate),
> date_part('month', article_pubdate) DESC;

The above means

    ... ORDER BY date_part('year', article_pubdate) ASC,
    date_part('month', article_pubdate) DESC;

You want

    ... ORDER BY date_part('year', article_pubdate) DESC,
    date_part('month', article_pubdate) DESC;

As noted by the other respondent, sorting on one date_trunc column is
probably the better way to do it, but I thought I'd point out the DESC
issue anyway.  A lot of people get that wrong.

            regards, tom lane

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

Предыдущее
От: Arnaud Lesauvage
Дата:
Сообщение: Re: levenshtein contrib installation
Следующее
От: Richard Broersma Jr
Дата:
Сообщение: Re: Sorting distinct dates by year and month respectively