SELECT NOT IN problem
Posted on 2008-06-11
A query I was using to generate a set of results has suddenly stopped producing results and I don't understand why.
I have 2 tables - Opportunities and Quotes. Each table is related to a customer table using UID.
I want to produce a set of results showing the customer UIDs for which we have raised quotes but not opportunities.
My query is as follows:
SELECT quotes.uid FROM quotes WHERE quotes.uid NOT IN (SELECT opportunities.uid FROM opportunities);
This was producing results but now it's not.
I've checked the individual tables and there are records that have quotes but not opportunities, so why has this suddenly stopped working?
This is a SQL 2000 database. I was running reports through an ASP intranet application, but since it stopped working, I've been testing this query in query analyzer.
Please tell me if I'm making a fundamental error or being stupid. I'm pulling my hair out!