From: Keith Worthington <KeithW@NarrowPathInc.com>
To: pgsql-sql@postgresql.org
Subject: week ending
Date: Thu, 06 Jul 2006 00:19:54 -0400
Message-ID: <44AC8F6A.4090704@NarrowPathInc.com> (raw)
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
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: KeithW@NarrowPathInc.com
Subject: Re: week ending
In-Reply-To: <44AC8F6A.4090704@NarrowPathInc.com>
* 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