Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL question
Burkhard Schultheis wrote in message
<19981226.7293619_at_Burkhard.Schultheis.dialin.t-online.de>...
>Hallo,
>if I have the following table:
>Nr Text
>-- ----
>1 'Text1'
>2 'Text2'
>4 'Text3'
>I want to search for the first 'free' Nr, which should be 3 in this
>case. How to do it with one select?
>Thank you in advance!
What about :
SELECT MIN ( a.nr + 1 )
FROM data a
WHERE NOT EXISTS (
SELECT 1 FROM data b WHERE b.nr = ( a.nr + 1) ) ;
--
Terje Tysse
terje_at_munck.no
Received on Mon Dec 28 1998 - 02:47:12 CST