Skip to content
Advertisement

SQL Group with time

Sample table

expect to see

My query

Output. But not sure why not group by hours

Advertisement

Answer

Based on this comment, it seems you just want to aggregate to the hours:

Try to group by each hours like between 8:00:00 to 8:59:00 and 9:00:00 to 9:59:00 and by dept.

If so, why not just use DATEPART with MIN and MAX?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement