• Something like the following?

    WITH absences AS (

    SELECT *, COUNT(absence_dt) OVER( PARTITION BY student_id ORDER BY attendence_dt ROWS UNBOUNDED PRECEDING) AS absence_cnt

    FROM attendence

    WHERE attendence_dt >= DATEADD(DAY, -30, @begin_dt)

    )

    SELECT *

    FROM absences

    WHERE absence_cnt = 7

    Drew

    Edit: Added ROWS UNBOUNDED PRECEDING

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA