Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odd issue with existence check in query 1

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
US
//results in >22000 records;
select distinct serial_no from customer;

//results in <7000 records;
select distinct serial_no from customer_serial;

//results in ~5000;
select count(*) from customer where serial_no in (select serial_no from customer_serial);

//results in 0;
select count(*) from customer where serial_no not in (select serial_no from customer_serial);

I'm not understanding how the 4th query could have zero results given the numbers in the prior queries.. Must be something wrong with my syntax..

Any thoughts?

Thanks,

-Stephen
 
What do you get for this???

Code:
select count(*) from customer where serial_no not in (select serial_no from customer_serial [!]Where serial_no Is Not Null[/!]);

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Doh, I can't believe I ignored that. You're both spot-on.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top