Re: Extract week from date

From: Dani Castaños <dcastanos(at)androme(dot)es>
To: 'Filip Rembiałkowski' <plk(dot)zuber(at)gmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Extract week from date
Date: 2009-05-18 15:19:50
Message-ID: 008101c9d7cc$16aff3e0$440fdba0$@es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dow!!! You’re ok! I forgot the aggregator funciont SUM!

Thanks!

De: Filip Rembiałkowski [mailto:plk(dot)zuber(at)gmail(dot)com]
Enviado el: lunes, 18 de mayo de 2009 16:54
Para: Dani Castaños
CC: pgsql-sql(at)postgresql(dot)org
Asunto: [?? Probable Spam] Re: [SQL] Extract week from date

2009/5/18 Dani Castaños <dcastanos(at)androme(dot)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(dot)rembialkowski(at)gmail(dot)com
http://filip.rembialkowski.net/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2009-05-18 15:22:54 Re: Extrapolating performance expectation
Previous Message Filip Rembiałkowski 2009-05-18 14:54:12 Re: Extract week from date