On Tue, 28 Oct 2003 12:38:05 -0800, "Joe"
<(E-Mail Removed)> wrote:
<posting a reply to a reply, sorry!>
>I have a table that list a person for every month that
>they had insurance coverage. There is no standard
>beginning month and no standard ending month. There is
>one record for each month they were effective with a
>begin and end date. For example:
>>John Doe 1/1/03 1-31-03
>>John Doe 2-1-03 2-28-03
>>John Doe 4-1-03 4-30-03
>>Jane Smith 4-1-03 4-30-03
>>Jane Smith 5-1-03 5-31-03
>>
>>I need to run a query that returns only members that
>have continuous dates over s specified time. i.e.
>Members effective for any continuous 12 month span
>regardless of begin or end dates.
A rather snarky Subquery (which migh be REALLY slow) should work:
SELECT MemberName, StartDate
FROM yourtable
WHERE (SELECT Count(*) FROM yourtable AS X
WHERE X.MemberID = yourtable.MemberID
AND X.StartDate >= DateAdd("m", -12, Yourtable.StartDate)) = 12;
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public