1

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

wildplasser
  • 43,142
  • 8
  • 66
  • 109
Masta
  • 81
  • 6
  • 3
    Have a look at https://blog.jooq.org/10-sql-tricks-that-you-didnt-think-were-possible/. #4 does what you're looking for. – Bill Jetzer Oct 21 '21 at 13:59
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 21 '21 at 14:00
  • – Bill Jetzer so much thanks!!! this is exactly what you need – Masta Oct 21 '21 at 20:42

0 Answers0