Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluating each record to evaluate datediff and summarize totals within a specific time frame

Status
Not open for further replies.

eshie003

Programmer
Mar 18, 2012
15
0
0
US
Hi,

I have a table with over 100K rows. See sample data attached:

SBSB_ID From Date Units
780000110 9/14/2011 8
780000110 10/3/2011 8
780000110 10/4/2011 6
780000110 10/5/2011 4
780000110 10/10/2011 3
780000110 12/8/2011 2
780000110 12/9/2011 4
780000110 12/13/2011 8
780000110 6/21/2012 4
780000114 6/19/2012 2
780000114 6/20/2012 2

What I need to do evaluate each record to identify the SBSB_ID record which contains a sum(units) >=80 within a 14 day period from the first From Date. I also need to identify the SBSB_ID record which contains a sum(units) >=100 within a 30 day period from the first From Date.

Once a SBSB_ID meets this criteria, I need to start over again by the next From Date after the criteria is met.

Is this possible? Thanks in advance for any help. :)
 
From the looks of your sample data, none meet your criteria.

Could you supply data that does meet your criteria and the expected result(s)?

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top