>I'm trying to make a query that, given N and a date, gives me the interval of
>N hours with the max(sum(...)).
select sum(i) as s, timestamp '2010-06-16 00:00:00' + extract(hour from
d)::integer/3*3 * interval '1 hour' as sumd from p group by extract(hour from
d)::integer/3 where d = '2010-06
I have found an initial solution. For an interval N of 3 hours the query can
be:
select distinct poi,first_value(start_date) OVER w as
start_date,first_value(end_date) OVER w as end_date,first_value(the_sum)
OVER w from
(select poi,t1.ts as start_date,
t1.ts + '3 hour'::interval as end_dat