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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to