Re: How to count NULL columns?
Posted in 1996
> Gateway@cornut.fr (Frederic Bouquet) writes:
> I tried the following command :
> select count(*) from table where mou_codlet not between "AAA" and "ZZZ">
> but the result returned is not the same as the following sql command
> select count(*) from table where mou_codlet not between "AAA" and "ZZZ" or
> mou_codlet is null>
> Is it normal that the null values are not included in the result of the first
> sql command ?
Yes.
Null is allways taken as false whatever the test in your where-clause is.
If mou_codlet is null in a row that row would not be counted whether you
say 'not between...' or '<> "AAA"' or any other test.
This works according to the SQL standard.
You allways have to test explisitily for null values with 'is null' or
'is not null'.
Nils.Myklebust@ccmail.telemax.no
NM Data AS, Postbox 9090, Gronland, 0133 Oslo, Norway
My opinions are those of my company