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

From: Leonardo F <m_lists(at)yahoo(dot)it>
To: stefano bonnin <stefano(dot)bonnin(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Given N, finding the interval of N hours with max(sum(..))
Date: 2010-06-17 13:32:16
Message-ID: 329833.11477.qm@web29008.mail.ird.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 from p 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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2010-06-17 14:14:53 Re: oid data types mapping in libpq functions
Previous Message Mike Christensen 2010-06-17 13:14:24 Re: [Blatant Alias Abuse] Anyone want to help out with a coding problem?