WITH IdTypes AS (
SELECT
date,
id_type,
Dense_Rank() OVER (ORDER BY date)
- Dense_Rank() OVER (PARTITION BY id_type ORDER BY date)
AS Seq
FROM
tmp
)
SELECT
Min(date) AS begin,
Max(date) AS end,
id_type
FROM IdTypes
GROUP BY id_type, Seq
ORDER BY begin
;