• JaybeeSQL - Tuesday, January 24, 2017 4:28 AM

    Very close, despite the fact that in retrospect my post was ambiguous.  Sorry I'm a DBA not used to delving this deep into code, but needs must. 

    When a student fails to attend class 2x per week, that is an issue/incident.  What I want (for now) is his most recent belt pass PRIOR to the incident.  Later I'll try to get clever and use this code as a base for Data Mining.

    The 'Cross Apply' was a nifty idea!  I wonder if it's possible to populate the @Logs temp table with values generated inline, possibly by my original Select, ie the inserted values don't need to be pasted in with every runtime.   I'm also intrigued by these 'Windowing' ?? functions.

    Perhaps giving those CREATE and INSERT statements pietlinden asked for will help us close that final gap for you.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk