Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 95929633D9C for ; Thu, 1 Oct 2009 22:06:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 72926-04 for ; Fri, 2 Oct 2009 01:06:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mail.postgresql.org (Postfix) with SMTP id 8A96D63358A for ; Thu, 1 Oct 2009 22:06:08 -0300 (ADT) Received: (qmail invoked by alias); 02 Oct 2009 01:06:05 -0000 Received: from unknown (EHLO [192.168.1.113]) [88.130.205.166] by mail.gmx.net (mp017) with SMTP; 02 Oct 2009 03:06:05 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX19F2dg6wOtF9SLO8ZXoBFwiK2clt8xq1WqHsNdijg pRucEvRct9GYiz Message-ID: <4AC55231.2080008@gmx.net> Date: Fri, 02 Oct 2009 03:06:57 +0200 From: Andreas User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Need magic for a moving statistic Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.72 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/7 X-Sequence-Number: 33206 Hi, I need some magic for a moving statistic that works on a rather big table starting at a given date within the table up until now. The statistic will count events allways on fridays over periods of 2 weeks before ... biweekly? So I'd like to get a line every 2 weeks for everthing between. I sadly don't know how to spell that does: collect data where insert_date between friday1 and friday1 + inteval '2 week' collect data where insert_date between friday1 + inteval '2 week' + inteval '1 second' and friday1 + inteval '4 week' collect data where insert_date between friday1 + inteval '4 week' + inteval '1 second' and friday1 + inteval '6 week' Is this possible ? regards