mkrausnick
Programmer
I tried to count records using IS NOT NULL in the WHERE clause, then using IS NULL in the where clause, then no where clause, and the sum of the first two counts do not equal the third count. How is this possible?
Background
I have a 7.5 million record transaction table to which I added a field ADDRID as char(10). Then I populated the field from another field in the table based on a condition:
To check the result, I counted the records by fiscal year:
The relevent results are:
2001-2002: 952,358
2002-2003: 972,257
Then I issued the query:
The relevent results are:
2001-2002: 952,350
2002-2003: 921,464
Lastly, I issued the query:
The relevent results are:
2001-2002: 861,209
2002-2003: 972,257
How can records be counted as both NULL and NOT NULL at the same time?
Mike Krausnick
Dublin, California
Background
I have a 7.5 million record transaction table to which I added a field ADDRID as char(10). Then I populated the field from another field in the table based on a condition:
Code:
update xact set ADDRID=left(OTHERFIELD,10) WHERE OTHERFIELD IS NOT NULL AND LEFT(OTHERFIELD,1) = '_'
To check the result, I counted the records by fiscal year:
Code:
select fy,count(*) from xact group by fy
2001-2002: 952,358
2002-2003: 972,257
Then I issued the query:
Code:
select fy,count(*) from xact where addrid IS NULL group by fy
2001-2002: 952,350
2002-2003: 921,464
Lastly, I issued the query:
Code:
select fy,count(*) from xact where addrid IS NOT NULL group by fy
2001-2002: 861,209
2002-2003: 972,257
How can records be counted as both NULL and NOT NULL at the same time?
Mike Krausnick
Dublin, California