I am trying to merge several adjacent dates to get one single entry.
For example I have the following absences for one Employee:
02-Mai-17 01-Apr-18
02-Apr-18 01-Apr-19
02-Apr-19 01-Apr-20
02-Apr-20 30-Aug-20
The result should be: 02-Mai-17 30-Aug-20
I tried it with Combine consecutive date ranges to merge adjacent dates, but it works for my understanding only for one additional adjacent date.
I uploaded an example database under https://www.file-upload.net/download-13581528/Database1.accdb.html
SELECT IT2001.Id, IT2001.Kind, IT2001.Start, IT2001.End, 'Typ1'
FROM IT2001 LEFT JOIN IT2001 AS IT2001_1 ON (IT2001.Id = IT2001_1.Id) AND (IT2001.Kind = IT2001_1.Kind) AND (IT2001.Start-1=IT2001_1.End)
WHERE IT2001_1.Id IS NULL
UNION ALL
SELECT IT2001.Id, IT2001.Kind, IT2001.Start, IT2001_1.End, 'Typ2'
FROM IT2001 INNER JOIN IT2001 AS IT2001_1 ON (IT2001.Id = IT2001_1.Id) AND (IT2001.Kind = IT2001_1.Kind) AND (IT2001_1.Start-1=IT2001.End)
and then:
SELECT Query1.Id, Query1.Kind, MIN(Query1.Start), Max(Query1.End)
FROM Query1
GROUP BY Query1.Id, Query1.Kind, Query1.Start
I am getting 3 rows instead of one:
02-Mai-17 01-Apr-19
02-Apr-18 01-Apr-20
02-Apr-19 30-Aug-20
How can I get one row or how could I delete the not required entries?