Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL question

Re: SQL question

From: Terje Tysse <terje_at_munck.no>
Date: Mon, 28 Dec 1998 09:47:12 +0100
Message-ID: <767gjb$sev$1@readme.online.no>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US