Re: Grouping by Week in Month

From: <artmerar_at_gmail.com>
Date: Thu, 2 May 2013 11:47:12 -0700 (PDT)
Message-ID: <7f0b51d4-c2c8-4d16-83b1-23c8409cc05b_at_googlegroups.com>



On Tuesday, April 30, 2013 9:32:32 AM UTC-5, artm..._at_gmail.com wrote:
> Hi,
>
>
>
> I am using this query to sum data for each week in the month:
>
>
>
> SELECT product_description, wk_start, wk_end, accepted, total
>
> FROM (SELECT service_id, TRUNC(date_sent+1,'IW')-1 wk_start, TRUNC(date_sent+1,'IW')+5 wk_end, SUM(accepted) accepted, SUM(list_count) total
>
> FROM trading_service_stats
>
> WHERE date_sent BETWEEN TRUNC(SYSDATE,'MM') AND
>
> TRUNC(LAST_DAY(SYSDATE)+1)
>
> GROUP BY service_id, TRUNC(date_sent+1,'IW')) a, email_products_vw e
>
> WHERE a.service_id = e.email_product_id
>
> ORDER BY wk_start, product_description;
>
>
>
> Today is 4/30/2013. The we_end value is 5/4/2013. What I am really looking for is the weeks within the calendar month.
>
>
>
> So, the first week for April 2013 should show 4/1 - 4/6. And the last week should show 4/28 - 4/30.
>
>
>
> Can anyone help me expand on this to get the date columns to actually be the week date ranges for the actual month?
>
>
>
> Thanks!

I got 2 words.....WOW & WOW!!

Very nicely done! Received on Thu May 02 2013 - 20:47:12 CEST

Original text of this message