Problem with result set from a simple SQL Select

From: lenny <lwintfeld_at_libertycorner.net>
Date: 28 Jan 2005 13:01:13 -0800
Message-ID: <1106946073.729415.225310_at_c13g2000cwb.googlegroups.com>



Hi

[Quoted] [Quoted] I'm making the following select in an Oracle 9i database:

select s.cusip, s.udf3, s.udf2 from trade t, security s where t.sec_sid [Quoted] = s.sec_sid and s.udf2 != 'CMO' and end_date >= '25-jan-05';

[Quoted] As expected, this does exclude records with values of 'CMO' in s.udf2 from my result set but for some reason it is ALSO excluding records with the value NULL/empty (I'm not sure which)in field s.udf2. I proved this by trying the following as an experiment:

select s.cusip, s.udf3, s.udf2 from trade t, security s where t.sec_sid = s.sec_sid and t.end_date >= '25-jan-05';

Here my result set includes records where s.udf2 has a value of 'CMO' and records where s.udf2 has a value of blank/NULL.

I don't understand why the first select statement is excluding empty/NULL values of s.udf2

How should I formulate a query which includes values of empty or NULL while excluding values of 'CMO' from s.udf2?

Is this problem (or "feature") peculiar to Oracle SQL or to most SQL implementations?

Please note the following:
1) s.udf2, s.udf3 and cusip are VARCHAR2's and end_date is type DATE.

2) Further qualifying end_date as t.end_date doesn't yield results with empty/NULL s.udf2's in them
Thanks in advance for any help

-Lenny Wintfeld Received on Fri Jan 28 2005 - 22:01:13 CET

Original text of this message