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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] Ordering a date_part() query ...
Дата
Msg-id 2228.948234397@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:
>> Uh, why don't you just GROUP BY and ORDER BY stat_period?

> Okay, maybe I'm misunderstanding GROUP BY, but my understanding is that it
> groups "like" values ... my above example would give me a count of all
> impressions received over a one hour period ...

Oh, so "stat_period" is not a period label but an exact timestamp,
and you want to group into hourly blocks?  OK, then group/order by
date_trunc("hour", stat_period) is probably what you want...

I'd suggest choosing another name for the field, too ;-)
        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 ...