Say i have a table with an integer column Id. I need to find the missing numbers
in a sequence
with a maximum returned amount.
- If the table is empty and i'm asking for 10, it should return the numbers 1-10.
- If the table has 1-5 and i'm asking for 10, it should return the numbers 6,7,8,9,10,11,12,13,14,15.
- If the table has 1,2,4,6,9 and im asking for 10, it should return the numbers 3,5,7,8,10,11,12,13,14,15
How can i achive this in one single query using MS SQL
?
Thanks in advance!