Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 524BA632E2C for ; Fri, 2 Oct 2009 09:46:23 -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 58774-09 for ; Fri, 2 Oct 2009 12:46:15 +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 38C72632716 for ; Fri, 2 Oct 2009 09:46:15 -0300 (ADT) Received: (qmail invoked by alias); 02 Oct 2009 12:46:12 -0000 Received: from unknown (EHLO [192.168.1.113]) [88.130.222.23] by mail.gmx.net (mp020) with SMTP; 02 Oct 2009 14:46:12 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX191+cZrA9R1DY1VceWoKbXfZTEfam1H2f3gZ1beZe 0RKHf8kWC/qNpx Message-ID: <4AC5F647.8030204@gmx.net> Date: Fri, 02 Oct 2009 14:47:03 +0200 From: Andreas User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: "A. Kretschmer" CC: pgsql-sql@postgresql.org Subject: Re: Need magic for a moving statistic References: <4AC55231.2080008@gmx.net> <20091002052916.GA22496@a-kretschmer.de> In-Reply-To: <20091002052916.GA22496@a-kretschmer.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.7 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/13 X-Sequence-Number: 33212 A. Kretschmer schrieb: > [...] Or simpler: > > test=*# select ((d-'2009-10-02'::date)/14) || '. period' as period, sum(value) from foo group by 1; > This is tricky, because you use a text-column to sort but need numerical sorting since there will be more than 0-9 periods. This is still the way to handle the periodity without pulling out some external skript language. Thanks for the reply. :)