This query gives me back 90 826
rows:
SELECT DISTINCT ClientID FROM devices;
Now I check how many of these are present in another table having the same column:
SELECT DISTINCT ClientID FROM devices
WHERE ClientID IN
(
SELECT DISTINCT ClientID FROM patients
);
This gives back 90 736
rows, so 90
rows should not be in this other table. Lets check this out to be sure:
SELECT DISTINCT ClientID FROM devices
WHERE ClientID NOT IN
(
SELECT DISTINCT ClientID FROM patients
);
But this gives me back an empty set, 0
rows. This shouldn't be right, so I go further, trying this:
SELECT DISTINCT ClientID FROM v_keszulekek
WHERE ClientID NOT IN
(
SELECT DISTINCT ClientID FROM devices
WHERE ClientID IN
(
SELECT DISTINCT ClientID FROM patients
)
);
This one gives me back the 90
rows indeed, but the first version should have worked as well in my opinion.
Clearly I am missing something.