Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>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?




-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux