Tuesday, 3 September 2013

SQl Query : how to aggregate on part of date

SQl Query : how to aggregate on part of date

I am puzzling how to do this in SQL (Jet flavored).. It is beyond my basic
SQL skills.
I have a reporting requirement against the to produce a list of products
bought (ie. product name), and the sum of the number of those items
ordered. Easy so far, but I also need the result aggregated by calendar
month to produce something similar to table below :
AUG JUL JUN JUL
widgets 23 54 67 67 ..... gadjets 12 34 33 19 .....
Orders table has a field called order_date
Order_Items table has fields product_name and items_purchased_count
The two tables join on order_id
Can someone help ? Is this even possible ? I have tried a number of things
but can't get close.
Thanks in advance. Bazza

No comments:

Post a Comment