I’m not sure if this syntax will work on your platform:
<pre>SELECT invno – 1
FROM invoices i
WHERE NOT EXISTS (
WHERE invno = i.invno – 1);</pre>
-The result will include a fictitious invoice number smaller than the lowest one.
-This query would perform better if an index exists on the invno field.
-This query will not detect contiguous blocks of missing invoice numbers.
See discussion below.