Given N, finding the interval of N hours with max(sum(..))

Поиск
Список
Период
Сортировка
От stefano bonnin
Тема Given N, finding the interval of N hours with max(sum(..))
Дата
Msg-id AANLkTimKVsr8Y5g_ReVAylAiJcWBDwtajTTcEKWgIdMP@mail.gmail.com
обсуждение исходный текст
Ответы Re: Given N, finding the interval of N hours with max(sum(..))  (stefano bonnin <stefano.bonnin@gmail.com>)
Re: Given N, finding the interval of N hours with max(sum(..))  (Leonardo F <m_lists@yahoo.it>)
Список pgsql-general
Hi all,
I'm trying to make a query that, given N and a date, gives me the interval of N hours with the max(sum(...)). In others words, given the following table:

2010-06-16 00:00:00 | 0
2010-06-16 01:00:00 | 2
2010-06-16 02:00:00 | 1
2010-06-16 03:00:00 | 5
2010-06-16 04:00:00 | 7
2010-06-16 05:00:00 | 9
2010-06-16 06:00:00 | 2
2010-06-16 07:00:00 | 0
2010-06-16 08:00:00 | 0
2010-06-16 09:00:00 | 0
2010-06-16 10:00:00 | 1
2010-06-16 11:00:00 | 2
2010-06-16 12:00:00 | 1
2010-06-16 13:00:00 | 1
2010-06-16 14:00:00 | 1
2010-06-16 15:00:00 | 1
2010-06-16 16:00:00 | 1
2010-06-16 17:00:00 | 1
2010-06-16 18:00:00 | 1
2010-06-16 19:00:00 | 1
2010-06-16 20:00:00 | 1
2010-06-16 21:00:00 | 0
2010-06-16 22:00:00 | 3
2010-06-16 23:00:00 | 1

With N = 3 and date = '2010-06-16' for example ... I'd like that the "query" gives me as response: the interval from 3AM and 5AM.
Any solutions and/or hints?

Thanks in advance.
stefano

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

Предыдущее
От: Dennis Gearon
Дата:
Сообщение: Re: world meaningful date time input
Следующее
От: Sergey Konoplev
Дата:
Сообщение: Re: Question about indexes on tables with inherited children