I'm trying to find a query to fill gaps between a start and end timestamp. The gaps/intervals should be minute wise. My goal is to get a time-series to create a diagram based on the results to visualize a time period for each record.
Sample date
create table tbl(
id int, value int, dateStart timestamp, dateEnd timestamp
);
insert into tbl values
(1, 4, '2020-01-04 16:29:00', '2020-01-04 16:33:00'),
(2, 3, '2020-01-04 18:29:00', '2020-01-04 18:33:00'),
(3, 3, '2020-07-16 09:10:00', '2020-07-16 09:12:00');
| id | value | dateStart | dateEnd |
| --- | -------- | ------------------- | ------------------- |
| 1 | 4 | 2020-01-04 16:29:00 | 2020-01-04 16:33:00 |
| 2 | 3 | 2020-01-04 18:29:00 | 2020-01-04 18:30:00 |
| 3 | 3 | 2020-07-16 09:10:00 | 2020-07-16 09:12:00 |
| . | . | . | . |
| . | . | . | . |
| . | . | . | . |
Expected Output
| id | value | date |
| --- | -------- | ------------------- |
| 1 | 4 | 2020-01-04 16:29:00 |
| 2 | 4 | 2020-01-04 16:30:00 |
| 3 | 4 | 2020-01-04 16:31:00 |
| 4 | 4 | 2020-01-04 16:32:00 |
| 5 | 4 | 2020-01-04 16:33:00 |
| 6 | 3 | 2020-01-04 18:29:00 |
| 7 | 3 | 2020-01-04 18:30:00 |
| 8 | 3 | 2020-07-16 09:10:00 |
| 9 | 3 | 2020-07-16 09:11:00 |
| 10 | 3 | 2020-07-16 09:12:00 |
I'm not very familiar with CTE and cursors, yet. Any suggestion/help how to solve it best?