Re: Whats the best query/solution for this problem
From: syliang <yongliangs_at_163.net>
Date: 1 Nov 2001 23:09:52 -0800
Message-ID: <54254e02.0111012309.2a61ea79_at_posting.google.com>
)
where nr=num
Date: 1 Nov 2001 23:09:52 -0800
Message-ID: <54254e02.0111012309.2a61ea79_at_posting.google.com>
select nvl(max(nr),0)+1
from(select nr,rownum as num
from( select nr from tablename order by nr)
)
where nr=num
pmartin_at_mitsa.ch (Paul) wrote in message news:<e582662.0111010531.5756cb16_at_posting.google.com>...
> Hello
> In a table we have a column (Nr) which contains numbers with holes in the
> sequence.
> What I need to do is to find the next lowest number to be used.
> ie:
>
> NR
> --
> 1
> 2
> 5
> 6
>
> next number = 3 then 4 then 7.
> I thought about using rownum to find the holes ie: rownum <> Nr what I am not
> sure how rownum works - does it number its rows after an order by of before an
> order by ?
> Any thoughts / ideas will be greatly appreciated
>
> Sincerely
>
> Paul
Received on Fri Nov 02 2001 - 08:09:52 CET