I would like to split the date range into respective months.
For example – I’ve a view which has data in the following way:
user project startdate enddate
-----------------------------------
A abc1 2011-01-01 2011-12-31
A abc2 2011-01-01 2011-05-01
B xyz1 2011-01-01 2011-03-01
I want to be able to display the above data in this way:
user project startdate enddate
A abc1 2011-01-01 2011-01-31
A abc1 2011-02-01 2011-02-28
A abc1 2011-03-01 2011-03-31
----------------------------------
A abc2 2011-01-01 2011-01-31
A abc2 2011-02-01 2011-02-28
----------------------------------
B xyz1 2011-01-01 2011-01-31
B xyz1 2011-02-01 2011-02-28
B xyz1 2011-03-01 2011-03-31
Can somebody help me with this?
The following query should do the trick. The
CTE(theWITHclause) dynamically generates some Month data that we can use to join against.