Hi Everyone,
I am working on a request here and I cant seem to get handle on it.
I am create a query that shows both MTD figures but also a YTD column.
Here is my query.
As I said The months come out fine the MTD column is what i want, but now I need a YTD column that will keep a running YTD number by month for example
Month MTD YTD
Jan 200 200
Feb 100 300
Mar 300 600
And then i have to figure out how to order the result by month.
I dont know if this is the best way to run this query but its the only way i could figure it out.
and help woudl be much appreciated.
-Sergio
I am working on a request here and I cant seem to get handle on it.
I am create a query that shows both MTD figures but also a YTD column.
Here is my query.
Code:
select
case when Month(a.event_date)=1 then 'January'
when Month(a.event_date)=2 then 'February'
when Month(a.event_date)=3 then 'March'
when Month(a.event_date)=4 then 'April'
when Month(a.event_date)=5 then 'May'
when Month(a.event_date)=6 then 'June'
when Month(a.event_date)=7 then 'July'
when Month(a.event_date)=8 then 'August'
when Month(a.event_date)=9 then 'September'
when Month(a.event_date)=10 then 'October'
when Month(a.event_date)=11 then 'November'
when Month(a.event_date)=12 then 'December'
else '' end as calendar_month_name
,sum(case
when Month(a.event_date) = 1 then 1
when Month(a.event_date) = 2 then 1
when Month(a.event_date) = 3 then 1
when Month(a.event_date) = 4 then 1
when Month(a.event_date) = 5 then 1
when Month(a.event_date) = 6 then 1
when Month(a.event_date) = 7 then 1
when Month(a.event_date) = 8 then 1
when Month(a.event_date) = 9 then 1
when Month(a.event_date) = 10 then 1
when Month(a.event_date) = 11 then 1
when Month(a.event_date) = 12 then 1
else ''end ) as MTD
As I said The months come out fine the MTD column is what i want, but now I need a YTD column that will keep a running YTD number by month for example
Month MTD YTD
Jan 200 200
Feb 100 300
Mar 300 600
And then i have to figure out how to order the result by month.
I dont know if this is the best way to run this query but its the only way i could figure it out.
and help woudl be much appreciated.
-Sergio