Re: [SQL] Ordering a date_part() query ...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] Ordering a date_part() query ...
Дата
Msg-id 1318.948224710@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [SQL] Ordering a date_part() query ...  (The Hermit Hacker <scrappy@hub.org>)
Ответы Re: [SQL] Ordering a date_part() query ...  (The Hermit Hacker <scrappy@hub.org>)
Список pgsql-sql
The Hermit Hacker <scrappy@hub.org> writes:
> SELECT ( date_part('month', stat_period) || '/' ||
>          date_part('day', stat_period)   || '/' ||
>          date_part('year', stat_period)  || ' ' ||
>          date_part('hour', stat_period)  || ':00:00' ) as "Summary - by Day/Hour",
>        sum(impressions) as impressions, sum(click_thru) as click_thru
>   FROM banner_count
> GROUP BY "Summary - by Day/Hour"
> ORDER BY "Summary - by Day/Hour"::datetime;


Uh, why don't you just GROUP BY and ORDER BY stat_period?

I also wonder whether you can't find a combination of date_trunc and
datestyle that will produce the output format you want.  Doing it
like the above sure seems like using the wrong tool for the job...
        regards, tom lane


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

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [SQL] Ordering a date_part() query ...
Следующее
От: The Hermit Hacker
Дата:
Сообщение: Re: [SQL] Ordering a date_part() query ...