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

Re: Theoretical question... very simple but complex problem dealing with negation.



Here's the code for Oracle; other databases would probably be similar.

Select
  'x' as result
from (Select count(*) as count from myTable where MyKey= 2) where count = 0

:-)

Allen




                        Ken Boettger
                        <BoettgeK@CWU.ED       To:       SQR-USERS@list.iex.net
                        U>                     cc:
                        Sent by:               Subject:  Theoretical 
question... very simple but complex problem dealing
                        "Discussion of           with negation.
                        SQR, Brio
                        Software's
                        database
                        reporting
                        language"
                        <SQR-USERS@list.
                        iex.net>


                        09/27/2002 02:51
                        PM
                        Please respond
                        to sqr-users






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