Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
moonshoe
Starting Member
2 Posts |
Posted - 2013-02-14 : 10:14:11
|
Hi,I am looking at spend data for individuals over 24 months (2 years). Say January 2010 to december 2012 on a rolling basis. So if I look at the month of January 2010, I'd like to pick only those individuals, who have spend data available for jan . For the same individuals for whom I have spend data available in January of 2010, I want to see, how many from this set is missing spend data in February of 2010. This will be my first population for analysis. For this population, I'd like to see the availability of spend data through december of 2012. I'd like to repeat this process for February 2010,pick individuals with spend data available in feb 2010, and from that population who have spend data in feb 2010, find the population for which spend is missing in March 2010, and this will be my second population for analysis for whom I'd like to see the availability of spend data through december of 2012I want to repeat this rolling process for 60 months until december 2012. How do I need to write this as a single query? Please help me with this.Hoping to hear from you.Moonshoe |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-14 : 10:20:32
|
do you've a calendar table in your database?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
moonshoe
Starting Member
2 Posts |
Posted - 2013-02-14 : 11:01:28
|
Yes I do have the date field in my datasetMoonshoe |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-14 : 12:04:04
|
Not date field. I was asking calendar table with all days ,months and years information------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|