• Lynn Pettis (4/11/2013)

    My question is what is the value of S.EndDate when this query was run.

    I'm taking it to mean that we need to "anchor" the #student table to return only a single version of each StudentID. With that in mind, will something like this work?

    selecte.StudentID,

    s.StudentKey,

    e.SchoolID,

    s.EnrolledSchoolKey,

    e.EntryDate,

    e.EntryCode,

    e.WithDrawalDate,

    e.WithDrawalCode

    from #student s

    join #enrollement e on s.enddate >= e.WithdrawalDate and s.StudentID = e.StudentID

    where s.StudentID = '0082600'

    and s.CurrentFlag = 1