Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 440D1634258 for ; Mon, 18 May 2009 12:00:53 -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 33996-02 for ; Mon, 18 May 2009 12:00:51 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f167.google.com (mail-ew0-f167.google.com [209.85.219.167]) by mail.postgresql.org (Postfix) with ESMTP id C09CC634302 for ; Mon, 18 May 2009 12:00:50 -0300 (ADT) Received: by ewy11 with SMTP id 11so4196292ewy.19 for ; Mon, 18 May 2009 08:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=9YDQ4ZbRtPXOtW8Mk5nndJpHhG4BL64teS1MlAGEsnk=; b=Un7MzZzQ1MmK8E6sfKZeMHHo63MZd/2vxf9skTIxIxwIH+gG13NJeZikkeQ6h5lE00 oesKWiWMMpqWetBVjrTI7zK+ckQalNbx6/4X6gmRdLj7/EV8lDHujsYGZdD74+EI9u6h V9uauG7L6MXz91XxL+aNP27iV/KS7mwx04C8o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=X2XmerqIdESBkw11MzCxhbZFMsHEE7vVcJVP94UnAcaathKZE7KTMaXdUC/MvrN5Ow wmBq/UbociabjEYEkqebkw4ZI0MKznLv9jiQ8+veo7VECRlk8utyi2dQa48lfgFcdrDK kCleuUlqIyN6lK34GQcL8It+tsMkZcRHDMFXU= MIME-Version: 1.0 Received: by 10.210.18.8 with SMTP id 8mr6723021ebr.86.1242658452972; Mon, 18 May 2009 07:54:12 -0700 (PDT) In-Reply-To: <007d01c9d7c6$af6aac70$0e400550$@es> References: <007d01c9d7c6$af6aac70$0e400550$@es> Date: Mon, 18 May 2009 16:54:12 +0200 Message-ID: <92869e660905180754u282e877ak22052a6188e4e037@mail.gmail.com> Subject: Re: Extract week from date From: =?UTF-8?Q?Filip_Rembia=C5=82kowski?= To: =?UTF-8?Q?Dani_Casta=C3=B1os?= Cc: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=0015174c43d8aaa6c0046a30f71e X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200905/82 X-Sequence-Number: 32574 --0015174c43d8aaa6c0046a30f71e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2009/5/18 Dani Casta=C3=B1os > Hi again, > > I need to extract date grouped by week from an statistics table. > > I was trying something like this: > > SELECT total_duration, EXTRACT( week from date statistics_date ) > FROM statistics_daily > GROUP BY EXTRACT( week from date statistics_date ), total_duration; > > But it doesn't works... Neither: > > SELECT total_duration, statistics_date > FROM statistics_daily > GROUP BY EXTRACT( day from statistics_date ), total_duration, > statistics_date; > > hmmm.. it's not clear what do you want. why not just something like SELECT EXTRACT( week from statistics_date ) as week, SUM( total_duration) as total_duration_sum FROM statistics_daily GROUP BY 1; ? --=20 Filip Rembia=C5=82kowski JID,mailto:filip.rembialkowski@gmail.com http://filip.rembialkowski.net/ --0015174c43d8aaa6c0046a30f71e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2009/5/18 Dani Casta=C3=B1os <dcastanos@androme.es>=
Hi again,

I need to extract date grouped by week from an statistics table.

I was trying something like this:

SELECT total_duration, EXTRACT( week from date statistics_date )
FROM statistics_daily
GROUP BY EXTRACT( week from date statistics_date ), total_duration;

But it doesn't works... Neither:

SELECT total_duration, statistics_date
FROM statistics_daily
GROUP BY EXTRACT( day from statistics_date ), total_duration,
statistics_date;


hmmm.. it's not clear what do you want.

w= hy not just something like

SELECT=C2=A0 EXTRACT( week from statistic= s_date ) as week, SUM(
total_duration) as total_duration_sum
FROM sta= tistics_daily GROUP BY 1;


?



--
Filip Rembia=C5= =82kowski
JID,mailto:fi= lip.rembialkowski@gmail.com
http://filip.rembialkowski.net/
--0015174c43d8aaa6c0046a30f71e--