From: Dani Castaños <dcastanos@androme.es>
To: 'Filip Rembiałkowski' <plk.zuber@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Extract week from date
Date: Mon, 18 May 2009 17:19:50 +0200
Message-ID: <008101c9d7cc$16aff3e0$440fdba0$@es> (raw)
In-Reply-To: <92869e660905180754u282e877ak22052a6188e4e037@mail.gmail.com>
References: <007d01c9d7c6$af6aac70$0e400550$@es>
<92869e660905180754u282e877ak22052a6188e4e037@mail.gmail.com>
Dow!!! You’re ok! I forgot the aggregator funciont SUM!
Thanks!
De: Filip Rembiałkowski [mailto:plk.zuber@gmail.com]
Enviado el: lunes, 18 de mayo de 2009 16:54
Para: Dani Castaños
CC: pgsql-sql@postgresql.org
Asunto: [?? Probable Spam] Re: [SQL] Extract week from date
2009/5/18 Dani Castaños <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łkowski
JID,mailto:filip.rembialkowski@gmail.com
http://filip.rembialkowski.net/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dcastanos@androme.es, plk.zuber@gmail.com
Subject: Re: Extract week from date
In-Reply-To: <008101c9d7cc$16aff3e0$440fdba0$@es>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox