0

This question is an extension capability related to my previous question here Update column with autonumber. Now with only one table this time:

Date        Adds
6/1/18      0
6/5/18      1
6/7/18      0
...+60 records
10/1/18     0

I would like to create a table of Dates, 60 date records (for ex) beyond the Date with a number in the New in Field. Using the previous method, here is what I have:

Select t1.adds,  t1.date from T1 where t1.adds > 0 AND
      (select count(*)+1 from t1 as t2 
      where t2.Date <= t1.Date AND t2.date >= 
               (select date from t1 as t3 where t3.date > t2.date) = 60)

I think everything would work except for the 2nd conditional statement where I need the date to be greater than the corresponding date where Adds > 0. If executed I would expect my table to look like:

Date       Adds
10/1/18    1
farmpapa
  • 31
  • 1
  • 8

1 Answers1

0

I think this works but unsure how efficient it is yet. I just made a tbltemp with Adds and Date where Adds > 0

SELECT q1.adds, t1.Date
FROM T1, tblTemp AS q1
WHERE (select count(*) from T1 as t2 where t2.date <= t1.date AND t2.date > q1.date)=60

I will do a little more testing with more records unless anyone has any better ideas?

farmpapa
  • 31
  • 1
  • 8