WITH recursive numbers AS (
select 0 as Date
union all
select Date + 1
from numbers
where Date < 10)
select * from numbers;
Create Table SampleTable
(
Start_Range Bigint,
End_Range Bigint
);
Insert into SampleTable Values (1,4);
Insert into SampleTable Values (6,6);
Insert into SampleTable Values (8,9);
Insert into SampleTable Values (11,13);
Insert into SampleTable Values (15,15);
with recursive CTE as
(
SELECT MIN(Start_Range) as id from SampleTable
UNION ALL
SELECT id+1 from CTE
where id < (select max(End_Range) from SampleTable)
)
SELECT id FROM CTE ,SampleTable where id>=Start_Range and id<=End_Range order by id;
No comments:
Post a Comment