My schedule table
ID | UserID | Date | status |
---|---|---|---|
1 | 1 | 2021-01-03 | vacation |
2 | 1 | 2021-01-04 | vacation |
3 | 1 | 2021-01-05 | present |
4 | 2 | 2021-01-01 | present |
5 | 2 | 2021-01-02 | vacation |
6 | 2 | 2021-01-03 | vacation |
6 | 2 | 2021-01-04 | vacation |
6 | 2 | 2021-01-05 | present |
7 | 2 | 2021-01-07 | vacation |
I tried doing a bit of logic using query from this example find start and stop date for contiguous dates in multiple rows
But I need to get output like this.
UserID | Start | End | status |
---|---|---|---|
1 | 2021-01-03 | 2021-01-04 | vacation |
2 | 2021-01-02 | 2021-01-04 | vacation |
2 | 2021-01-07 | 2021-01-07 | vacation |