Re: Select/Group by/Order by question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Select/Group by/Order by question
Дата
Msg-id 21483.1081489477@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Select/Group by/Order by question  (Mike Nolan <nolan@gw.tssi.com>)
Ответы Re: Select/Group by/Order by question  (Mike Nolan <nolan@gw.tssi.com>)
Список pgsql-general
Mike Nolan <nolan@gw.tssi.com> writes:
>    select  to_char(mtrantime,'mm-dd hh AM') as datetime,
>    count(*) as tot from memtran
>    group by datetime
>    order by datetime;
> The problem is this produces the data in the following order:
> ...
> What I'd really like is to get it in chronological order by hour:

You are grouping/ordering by the textual result of to_char(),
in which PM naturally follows AM.  I think the behavior you
want would come from grouping/ordering by the underlying
timestamp column "mtrantime".

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Upgrading from 7.3.6 to 7.4.2 pg_dumpall question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_ctl problem