SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Rolling month over month data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

moonshoe
Starting Member

USA
2 Posts

Posted - 02/14/2013 :  10:14:11  Show Profile  Reply with Quote
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 2012

I 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

India
52325 Posts

Posted - 02/14/2013 :  10:20:32  Show Profile  Reply with Quote
do you've a calendar table in your database?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

moonshoe
Starting Member

USA
2 Posts

Posted - 02/14/2013 :  11:01:28  Show Profile  Reply with Quote
Yes I do have the date field in my dataset

Moonshoe
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/14/2013 :  12:04:04  Show Profile  Reply with Quote
Not date field. I was asking calendar table with all days ,months and years information

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000