I guess that is part of the problem. As for the math, I am not sure what you are meaning. The logic is the tricky part. As I understand it the DATEDIFF is currently making sure that a dog has entered at least two events with a difference in dates greater than four days, and if that case is true, then the query is counting all of the dog's entries...
I guess in writing this it has cleared my head of what the logic needs to be...
I need it to count all entries that have a date within 4 days of each other as one entry. Does that make sense?
DOG
DATE
1
8/20/2010
1
8/21/2010
1
8/13/2010
1
8/14/2010
1
8/7/2010
1
8/8/2010
1
8/1/2010
1
8/2/2010
2
8/20/2010
2
8/13/2010
2
8/14/2010
2
8/7/1010
2
8/1/2010
3
8/20/2010
3
8/13/2010
3
8/14/2010
3
8/8/2010
With the above data the results I am currently getting are:
DOG 1 = 8, DOG 2 = 5, DOG 3 = 4
The desired results would be:
DOG 1 = 4, DOG 2 = 4, DOG 3 = 3
I hope that helps clarify what I am trying to do better.