Darkwing99
Programmer
I have a table where COL1 is an increasing number starting with 1.
Rows can be deleted.
Now I need a SELECT-statement to get the first unused number within a given range.
Example:
COL1
1
2
3
4
6
8
12
13
14
I neet the first free number between 10 and 20.
The result has to be 10.
How can I select this value?
The best statement I explored is:
But this SQL will bring the result 15 in the example, not 10.
Thanks for help.
Regards,
Thomas
Rows can be deleted.
Now I need a SELECT-statement to get the first unused number within a given range.
Example:
COL1
1
2
3
4
6
8
12
13
14
I neet the first free number between 10 and 20.
The result has to be 10.
How can I select this value?
The best statement I explored is:
Code:
SELECT MIN(COL1) + 1
FROM TABLE_1
WHERE
COL1 > :LOW-RANGE - 1
AND COL1 < :HIGH-RANGE - 1
AND COL1 NOT IN
( SELECT COL - 1 FROM TABLE_1 )
But this SQL will bring the result 15 in the example, not 10.
Thanks for help.
Regards,
Thomas