I have a column of type integer and the records has numbers from 1 to 270 so far. I’d like to write a query that returns numbers that are not in the database between 1 and 270.
e.g. number 5, 10, 15, 117 are missing. So that query should return these numbers.
And there are some numbers missing because the count of records is less than 270 and it’s unpractical to search it with eye.
thank you
Do a self join to find consecutive numbers, and where there is no match, you have a missing number.
But this doesn’t find all missing numbers, only the ones that are one less than a number that is present. If all your gaps are only one number, this is okay. But if you have gaps that are sequences of two or more numbers, you may have to use an alternative technique:
Create a table and fill it with integers at least 1 to 270:
Now you can do an outer join to search for those integers missing in your original table: