I have a query that creates several columns 12 of which are for each month of the year. I cannot simply name them January, February, etc.....This would work fine if I was always looking for data for the calendar year (Jan - Dec). I am not though, it is always 12 months but could be February of 2015 through January of 2016. These dates are based on the input of the user.
Here is an example of the piece of the code I am referencing above:
isnull ( sum ( case when month(mm.ReportingMonth) = 01 then mm.membermonths end ),0) as 'January'
I do not want to name this 'January' though but would like it to be named dynamically based on user input. Something like month(mm.reportingmonth)+year(mm.reportingmonth).
I don't know how to do that though, can anyone please help me?