Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 7413D633C34 for ; Mon, 18 May 2009 12:19:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 00302-06-2 for ; Mon, 18 May 2009 12:19:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) by mail.postgresql.org (Postfix) with ESMTP id 96D536350C4 for ; Mon, 18 May 2009 12:19:52 -0300 (ADT) Received: by fafnir.androme.com (Postfix, from userid 1003) id 428AEB9191A; Mon, 18 May 2009 17:19:51 +0200 (CEST) From: =?utf-8?Q?Dani_Casta=C3=B1os?= To: =?utf-8?Q?'Filip_Rembia=C5=82kowski'?= Cc: References: <007d01c9d7c6$af6aac70$0e400550$@es> <92869e660905180754u282e877ak22052a6188e4e037@mail.gmail.com> In-Reply-To: <92869e660905180754u282e877ak22052a6188e4e037@mail.gmail.com> Subject: Re: Extract week from date Date: Mon, 18 May 2009 17:19:50 +0200 Message-ID: <008101c9d7cc$16aff3e0$440fdba0$@es> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0082_01C9D7DC.DA38C3E0" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcnXyIHt/E09E8dcQUG3WD63sECQ6AAA4Wfw Content-Language: es X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=-0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200905/83 X-Sequence-Number: 32575 Este es un mensaje con varias partes en formato MIME. ------=_NextPart_000_0082_01C9D7DC.DA38C3E0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Dow!!! You=E2=80=99re ok! I forgot the aggregator funciont SUM! =20 Thanks! =20 De: Filip Rembia=C5=82kowski [mailto:plk.zuber@gmail.com]=20 Enviado el: lunes, 18 de mayo de 2009 16:54 Para: Dani Casta=C3=B1os CC: pgsql-sql@postgresql.org Asunto: [?? Probable Spam] Re: [SQL] Extract week from date =20 =20 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.=20 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/ ------=_NextPart_000_0082_01C9D7DC.DA38C3E0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Dow!!! You=E2=80=99re ok! I forgot the = aggregator funciont SUM!

 

Thanks!

 

De: Filip = Rembia=C5=82kowski [mailto:plk.zuber@gmail.com]
Enviado el: lunes, 18 de mayo de 2009 16:54
Para: Dani Casta=C3=B1os
CC: pgsql-sql@postgresql.org
Asunto: [?? Probable Spam] Re: [SQL] Extract week from = date

 

 

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.

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;



?



--
Filip Rembia=C5=82kowski
JID,mailto:filip.rembialkowski@gmail.c= om
http://filip.rembialkowski.net/<= /a>

------=_NextPart_000_0082_01C9D7DC.DA38C3E0--