pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedExtract week from date
3+ messages / 2 participants
[nested] [flat]
* Extract week from date
@ 2009-05-18 14:41 Dani Castaños <dcastanos@androme.es>
2009-05-18 14:54 ` Re: Extract week from date Filip Rembiałkowski <plk.zuber@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Dani Castaños @ 2009-05-18 14:41 UTC (permalink / raw)
To: pgsql-sql
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;
How can it be done?
Note: statistics_date is a DATE data type column.
Regards.
--
Dani Castaños Sánchez
dcastanos@androme.es
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Extract week from date
2009-05-18 14:41 Extract week from date Dani Castaños <dcastanos@androme.es>
@ 2009-05-18 14:54 ` Filip Rembiałkowski <plk.zuber@gmail.com>
2009-05-18 15:19 ` Re: Extract week from date Dani Castaños <dcastanos@androme.es>
0 siblings, 1 reply; 3+ messages in thread
From: Filip Rembiałkowski @ 2009-05-18 14:54 UTC (permalink / raw)
To: Dani Castaños <dcastanos@androme.es>; +Cc: pgsql-sql
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/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Extract week from date
2009-05-18 14:41 Extract week from date Dani Castaños <dcastanos@androme.es>
2009-05-18 14:54 ` Re: Extract week from date Filip Rembiałkowski <plk.zuber@gmail.com>
@ 2009-05-18 15:19 ` Dani Castaños <dcastanos@androme.es>
0 siblings, 0 replies; 3+ messages in thread
From: Dani Castaños @ 2009-05-18 15:19 UTC (permalink / raw)
To: 'Filip Rembiałkowski' <plk.zuber@gmail.com>; +Cc: pgsql-sql
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/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2009-05-18 15:19 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-05-18 14:41 Extract week from date Dani Castaños <dcastanos@androme.es>
2009-05-18 14:54 ` Filip Rembiałkowski <plk.zuber@gmail.com>
2009-05-18 15:19 ` Dani Castaños <dcastanos@androme.es>
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