Home Forums SQL Server 2008 SQL Server Newbies Sum the Attendance Hours by Category and then Group by 'Week of' RE: Sum the Attendance Hours by Category and then Group by 'Week of'

  • I have tried datepart(wk, Date). It groups by week (datepart(wk, Date)) and then displays the first entry of that week, not the first day in the week, necessarily

    select DOP_ID,

    (First_Name + ' ' + Last_Name) as Name,

    Category,

    min(Date) as WeekOf,

    sum(Hours) as TotalHours

    FROM [GW_PPP].[dbo].[SLAM_Attendence]

    where DOP_ID in (select DOP_ID from [GW_PPP].[dbo].[SLAM_Status] where STATUS ='Enrolled')

    and Category in ('GED Program', 'Lit/Num Combined (Pre-GED)')

    group by DOP_ID,Category, datepart(wk, Date)