Re: Query to find first missing integer in a field

From: <>
Date: Tue, 7 Apr 2009 17:51:27 -0700 (PDT)
Message-ID: <>

On Apr 7, 3:51 pm, dean <> wrote:
> Does anyone know a good way to find the first free integer number that
> does not exist in a table in a specified column? I can think of a
> couple of tedious ways of doing this but they are hardly elegant.
> Assume there could be any integer present up to 2 billion.

Why don't you create a new table? Select the data that you want from an existing table get some kind of order by and use rownum as your new not missing integer.

Better yet stay away from the database entirely and stick the data into some spreadsheet and let the excel jockeys fix it any way they wish to as long as they don't put it back in. Received on Tue Apr 07 2009 - 19:51:27 CDT

Original text of this message