On Tue, Sep 14, 2004 at 02:30:43PM -0500, NIPP, SCOTT V (SBCSI) wrote:
>       I have a table that has a list of users with numeric user IDs.
> The user IDs are not sequential.  There are large gaps in the list of
> numeric IDs.  I want to pick the next unused number beginning at 3000.
> How do I do this?

Off the top of my head, without checking it, something along these
lines might work:

        SELECT t1.id+1
        FROM table t1 LEFT OUTER JOIN table t2 ON (t2.id = t1.id + 1)
        WHERE t2.id IS NULL
        AND t1.id >= 3000

Tim.

Reply via email to