Re: Group by range in hour of day

Поиск
Список
Период
Сортировка
От Israel Brewster
Тема Re: Group by range in hour of day
Дата
Msg-id 2E39E3BC-2829-4A23-A33B-105D13260E8D@ravnalaska.net
обсуждение исходный текст
Ответ на Re: Group by range in hour of day  (Paul Jungwirth <pj@illuminatedcomputing.com>)
Список pgsql-general
On Mar 16, 2015, at 2:16 PM, Paul Jungwirth <pj@illuminatedcomputing.com> wrote:
>
>> I have a table with two timestamp columns for the start time and end
>> time of each record (call them start and end).I'm trying to figure out
>> if there is a way to group these records by "hour of day",
>
> I think you can do this by selecting `FROM generate_series(0, 23) s(h)` and then joining to your table based on `h
BETWEENstart AND end`. 
>
> Whenever I need to write a time-series aggregate query I reach for generate_series. Mostly that's so I have output
rowseven when COUNT(*) would be 0, but here it also means that a row from your data can feed into multiple output rows. 
>
> I could probably write this out in more detail if you like, but that's the short version. :-)

I think I can work with that :-) Hadn't considered doing a join there, so that's a new approach I can investigate.
Thanks!
>
> Good luck!
>
> Paul
>
>
>
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general



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

Предыдущее
От: Israel Brewster
Дата:
Сообщение: Re: Group by range in hour of day
Следующее
От: John W Higgins
Дата:
Сообщение: Re: Group by range in hour of day