| From: | Keith Worthington <KeithW(at)NarrowPathInc(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | week ending |
| Date: | 2006-07-06 04:19:54 |
| Message-ID: | 44AC8F6A.4090704@NarrowPathInc.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Hi All,
I just finished writing a query that groups data based on the week number.
SELECT EXTRACT(week FROM col_a) AS week_number,
sum(col_b) AS col_b_total
FROM foo
WHERE foobar
GROUP BY EXTRACT(week FROM col_a)
ORDER BY EXTRACT(week FROM col_a);
I would like to generate the starting date or ending date based on this
number. IOW instead of telling the user "week number" which they won't
understand I would like to provide either Friday's date for "week
ending" or Monday's date for "week beginning".
SELECT <something> AS week_ending,
sum(col_b) AS col_b_total
FROM foo
WHERE foobar
GROUP BY EXTRACT(week FROM col_a)
ORDER BY EXTRACT(week FROM col_a);
--
Kind Regards,
Keith
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rodrigo De Leon | 2006-07-06 07:00:17 | Re: week ending |
| Previous Message | Davi Leal | 2006-07-05 22:07:06 | Re: Foreign Key: what value? -- currval() |