Hello,
I'm using sql 2008 R2 standard edition.
I have a table containing activities with columns ActivityID, StartDate, EndDate. Few sample data:
acvtivityID StartDate EndDate
12345 12-22-2013 01-04-2014
12346 12-28-2013 NULL
12347 01-16-2014 02-17-2014
12348 01-17-2014 03-28-2014
12349 03-21-2014 NULL
Now i want a query which gives the count of open activities at each end of month, e.g.:
date Openactivities
12-31-2013 21
01-31-2014 20
02-28-2014 12
03-31-2014 23
...etc..
so for example, on march 31, 2014 the number of open activities is the count(activityID) where startdate <= 3-31-2014 and the EndDate >= 3-31-2014 or EndDate IS NULL. And some way it has to be grouped by eahc end of month..
How to do this?
Regards, Hennie