-- Stripped down version. Nothing useful any longer. Crashed on MariaDB 10.3.30, 10.4.20, 10.5.11, 10.6.3 but not with respectively older version
-- Client: /* SQL Error (2013): Lost connection to MySQL server during query */
-- Server (Windows 10): mysqld.exe service crashed with "Event 1000, Application Error"

USE mysql;

SET @DateListCounter = -1;

WITH RECURSIVE `SequenceWithHour` AS (
	SELECT '12:00:00' AS `Hour`
)

,`DateCounter` AS (
   SELECT 1 AS `DateCounter`
   UNION ALL
   SELECT `DateCounter` + 1
   FROM `DateCounter`
	WHERE `DateCounter` < 365
)

,`DateList` AS (
	SELECT DATE(ADDDATE('2021-01-01', INTERVAL @DateListCounter := @DateListCounter + 1 DAY)) AS `Date` FROM `DateCounter`
)

,`SequenceDateHour` AS (
	SELECT		`Date`, `Hour`
	FROM 			`SequenceWithHour`
	CROSS JOIN	`DateList`
)

,`SequenceDateHourBuildingWorkplace` AS (
	SELECT		1
	FROM 			`SequenceWithHour`
	CROSS JOIN	`DateList`
)

,`SleepPerDayBuildingWorkplaceHour` AS (
	SELECT	1
	FROM		(SELECT 1) tab1
	CROSS JOIN	`SequenceDateHourBuildingWorkplace` tab2
)

-- SELECT * FROM `SequenceWithHour`;
-- SELECT * FROM `DateCounter`;
-- SELECT * FROM `DateList`;
-- SELECT * FROM `SequenceDateHour`;
 SELECT * FROM `SequenceDateHourBuildingWorkplace`;
-- SELECT * FROM `SleepPerDayBuildingWorkplaceHour`;