G
Guest
Hello,
I am trying to figure out a way to tell how many consecutive days there is a
schedule entry for a person in a table. I've set up a query to yield a
person-day combination to filter out entries I don't want and the resulting
query is called qryDateProjectPerson with fields PrimaryID and ScheduleDate.
What I would like is something like this:
Name StartDate ConsecutiveDays
Sally 9/22/07 8
Jane 9/15/07 10
Sally 10/25/07 11
Unfortunately, the closest I can come is by using another post which tallied
up occurrences:
SELECT DISTINCT qryDateProjectPerson.PrimaryID, (SELECT Nz(Count(*) +
Sum((Select Nz(MIN(A.ScheduleDate)) FROM qryDateProjectPerson AS A
WHERE A.ScheduleDate > B.ScheduleDate AND A.PrimaryID =
qryDateProjectPerson.PrimaryID) = DateAdd('d', 1, B.ScheduleDate)),0)
FROM qryDateProjectPerson AS B WHERE B.PrimaryID =
qryDateProjectPerson.PrimaryID) AS Occurrence
FROM qryDateProjectPerson;
Any ideas would be super-appreciated.
I am trying to figure out a way to tell how many consecutive days there is a
schedule entry for a person in a table. I've set up a query to yield a
person-day combination to filter out entries I don't want and the resulting
query is called qryDateProjectPerson with fields PrimaryID and ScheduleDate.
What I would like is something like this:
Name StartDate ConsecutiveDays
Sally 9/22/07 8
Jane 9/15/07 10
Sally 10/25/07 11
Unfortunately, the closest I can come is by using another post which tallied
up occurrences:
SELECT DISTINCT qryDateProjectPerson.PrimaryID, (SELECT Nz(Count(*) +
Sum((Select Nz(MIN(A.ScheduleDate)) FROM qryDateProjectPerson AS A
WHERE A.ScheduleDate > B.ScheduleDate AND A.PrimaryID =
qryDateProjectPerson.PrimaryID) = DateAdd('d', 1, B.ScheduleDate)),0)
FROM qryDateProjectPerson AS B WHERE B.PrimaryID =
qryDateProjectPerson.PrimaryID) AS Occurrence
FROM qryDateProjectPerson;
Any ideas would be super-appreciated.