I have PersonId and his special days. I need partition this dates to periods.
Current table:
+----------------+-------------+
|EmployeePosition|DeviationDays|
+----------------+-------------+
|1925 |2021-09-06 |
|1925 |2021-09-08 |
|1925 |2021-09-09 |
|1925 |2021-09-21 |
|1925 |2021-09-22 |
|1925 |2021-09-23 |
|1925 |2021-10-07 |
|1925 |2021-10-08 |
+----------------+-------------+
Table what i need:
+----------------+-------------+-------------+-------------+
|EmployeePosition|DateStart |DateEnd |CountDays |
+----------------+-------------+-------------+-------------+
|1925 |2021-09-06 |2021-09-06 |1 |
|1925 |2021-09-08 |2021-09-09 |2 |
|1925 |2021-09-21 |2021-09-23 |3 |
|1925 |2021-10-07 |2021-10-08 |2 |
+----------------+-------------+-------------+-------------+
Sequential dates should be union to "periods",
Thanks for any help