[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Theoretical question... thanks



Cool.

I obtained a response from a co-worker here. Similar to Don's.  There were some 
other solutions there too (Samir). Mine will go something like this:

Select 'N' from PS_INSTALLATION dummy_tbl
     where 'P' <> (Select 'P' from MyTable where MyKey = 2)

Thanks to all for the input.

-Ken




Ken Boettger
boettgek@cwu.edu
http://www.cwu.edu/~boettgek
x2944

>>> donm@ONTKO.COM 09/27/02 12:13PM >>>
If you have to do this entirely within SQL then something like...

select 'x'
from dual
where not exists (select 'x'
                  from MyTable
                  where MyKey = 2)

HTH,
Don

On Fri, 27 Sep 2002, Ken Boettger wrote:

> I have a table entitled MyTable. It has only one field, MyKey.
>
> There are only three records in the table with MyKey values of 1, 2 and
> 3 respectfully.
>
> Write a SQL statement that RETURNS NO RECORDS when you successfully find
> a key value (aka, where MyKey = 2).
>
> Concurrently, the SQL should return one and only one record or data
> element (ie, select 'x') when the key value does not exist (aka,
> something should be returned when you test for MyKey = '7').
>
>
> I have a much more complex problem but this simple version sheds some light 
>on the issue I am facing.  If someone knows how to address this, I would be 
>interested in your solution.
>
> -Ken
>
>
>
> Ken Boettger
> boettgek@cwu.edu
> http://www.cwu.edu/~boettgek
> x2944
>

-----------------------------------------------------------------------
Donald Mellen  | Ray Ontko & Co. - Richmond, IN - http://www.ontko.com/
donm@ontko.com |  "In the beginning, there was nothing, which exploded"