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
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;