Re: Given N, finding the interval of N hours with max(sum(..)) - Mailing list pgsql-general

From Leonardo F
Subject Re: Given N, finding the interval of N hours with max(sum(..))
Date
Msg-id 329833.11477.qm@web29008.mail.ird.yahoo.com
Whole thread Raw
In response to Given N, finding the interval of N hours with max(sum(..))  (stefano bonnin <stefano.bonnin@gmail.com>)
List pgsql-general
>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
fromp group by extract(hour from d)::integer/3 where d = '2010-06-16 00:00:00' order by s desc limit 1; 

is this what you're looking for?




pgsql-general by date:

Previous
From: Mike Christensen
Date:
Subject: Re: [Blatant Alias Abuse] Anyone want to help out with a coding problem?
Next
From: Adrian Klaver
Date:
Subject: Re: oid data types mapping in libpq functions