Hi. The above is great, Thanks! Just want I need. Below was the original example code I was working off of to try and get the 2nd requirement (with the sum at 60 instead of 120, so one student reaches it, using the sample dataset.). I am having trouble modifying it to get it to work.
select ID
, Category
, min(Date) as WeekOf
, sum(Hours) as TotalHours
from Attendance
group by
ID
, Category
, datepart(wk, Date);
select ID
, min(Date)
from (
select ID
, Date
, sum(Hours) over (partition by ID order by Date) RunningSum
, Hours
from Attendance
) as SubQueryAlias
where RunningSum >= 60
group by
ID;