Hi! I am trying to find some results NOT in a resultset
The query I am using to get the resultset:
This gives me 5 results.Code:SELECT BD.id, BD.a_id, CONVERT(varchar, A.agent_id) + ' ' + A.fname + ' ' + A.lname AS name, BD.b_id, BD.agent_id, BD.inactive, BD.english, BD.french, BD.province FROM Univlicval_billing_digits AS BD INNER JOIN Univlicval_agents AS A ON BD.a_id = A.id WHERE (BD.b_id = 3) AND (BD.province = 'AB')
I want to get the rest of the agents that are not already assigned to the b_id AND province.
I run this query:
And get a complete resultset from agents (24 rows) where I should have 18 rows.Code:SELECT DISTINCT id, agent_id, fname, lname, inactive FROM Univlicval_agents AS A WHERE (NOT EXISTS (SELECT a_id FROM Univlicval_billing_digits AS BD WHERE (A.id = a_id) AND (b_id = 3) AND (province = 'AB')))
I know I'm missing something simple, but I can't figure out what it is. Thanks in advance!
Thanks in advance!



Reply With Quote
Bookmarks