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