Here’s the data:
empID Date Type
----- -------- ----
1 1/1/2012 u
1 1/2/2012 u
1 1/3/2012 u
1 2/2/2012 u
4 1/1/2012 u
4 1/3/2012 u
4 1/4/2012 u
4 1/6/2012 u
Would return:
empID count
----- -----
1 2
4 3
When two dates are “together” they count as one occurrence, if the dates are separated out, they count as two occurrences. This is for tracking employee attendance… how would the SQL statement look to group by “together” dates and count them as 1… I’m really struggling with the logic.
1 Answer