I have a table in which I enter attendance of every employee including annual leave (code: LAn
) or casual leave (code: LCa
).
+-------+-----------+-----+
| ID | Date | Att |
+-------+-----------+-----+
| 9999 | 01-Jul-19 | LCa |
| 9999 | 02-Jul-19 | LCa |
| 9999 | 03-Jul-19 | LCa |
| 10000 | 15-Jul-19 | LAn |
| 10000 | 16-Jul-19 | LAn |
| 10000 | 17-Jul-19 | LAn |
| 10000 | 18-Jul-19 | LAn |
| 10000 | 19-Jul-19 | LAn |
| 9999 | 22-Jul-19 | LCa |
| 9999 | 23-Jul-19 | LCa |
| 9999 | 24-Jul-19 | LCa |
+-------+-----------+-----+
I am working in MS Access 2016.
It is very similar to this problem: How do I group on continuous ranges, but I want a solution in MS Access. Can anyone help me out please?
I want the query to partition data based on dates so that the output looks something like this:
+-------+-----------+-----------+------+-----+
| ID | DateFrom | DateTo | Days | Att |
+-------+-----------+-----------+------+-----+
| 9999 | 01-Jul-19 | 03-Jul-19 | 3 | LCa |
| 10000 | 15-Jul-19 | 19-Jul-19 | 5 | LAn |
| 9999 | 22-Jul-19 | 24-Jul-19 | 3 | LCa |
+-------+-----------+-----------+------+-----+