I have a table with columns Category, Date, Monthly_Revenue.
I need a query that will select Todays_Month, Last_Month, 2 months prior, Last_years_Month, average of today’s month, average of all months.
This query is needed grouped by category.
Example :
Category | Sept, 2012 | Aug, 2012| Jul, 2012 | Sept, 2011 | Average of Sept | Avg all Mo
Being fairly new to SQL I still haven’t got it yet. I figured see if somebody out there could take a crack at it. Thanks.
Sample data
'Burger' '9/1/2012' '500'
'Fries' '10/1/2012 '300'
'Burger' '6/1/2011' '250'
you need something along these lines .Not the optimum solution but will give you a start
.This is a static solution but it looks like you may want a dynamic solution
*not tested