produce a range of numbers with select from the gaps of ID column
(1)
Suppose I have a table t which has rows like this:
A B
---------- ----------
2 4
6 7
I would like to use select to produce rows with numbers ranging between A column and B column inclusive
for each row, like this:
select ... from t ...
2
3
4
6
7
(2)
Suppose I have ID column which has gaps, I would like to get lowest <N> available numbers between the gaps.
I did research, and I can find the range of the gaps, but I cannot have the numbers listed individually, that is why
I ask question (1). But is there a direct way to get the list instead of going through ranges and the list.
For example, I have ID column which has
2
5
6
7
9
2000000
I would like to get a select query that produces
select ...
3
4
8
10
11
I have a way to get a list from 2 to 2000000 and then minus what we have to get all the
gap numbers, but that is not efficient and could runs out of memory.
PS: Before I post to this group, I did research already on "connect by", with recursive queries.