I'm building a system that should show when the students missed two days in a row. For example, this table contains the absences.
day | id | missed
----------------------------------
2016-10-6 | 1 | true
2016-10-6 | 2 | true
2016-10-6 | 3 | false
2016-10-7 | 1 | true
2016-10-7 | 2 | false
2016-10-7 | 3 | true
2016-10-10 | 1 | false
2016-10-10 | 2 | true
2016-10-10 | 3 | true
(days 2016-10-8 and 2016-10-9 are weekend)
in the case above:
- student 1 missed the days 1st and 2nd. (consecutive)
- student 2 missed the days 1st and 3rd. (nonconsecutive)
- student 3 missed the days 2nd and 3rd. (consecutive)
The query should select only student 1 and 3.
Is possible to do stuff like this just with a single SQL Query?