Relative Content

Tag Archive for sqldatabasedatatablessubquery

How to get records for one customer that exist in two tables but in one of them there are more

How to get records for one customer that exist in two tables but in one of them there are more records. For example in the fist table there are 3 records with different amounts and in the second there are only two of the same recoreds. I need a SQL query to get records from first table that are missing in the second one. If I joint the tables and add where second table.field IS NULL forks only if the customer exists in both tables the record is not in the results.
First Table
Second Table
This query works only in the mentioned above case:
SELECT * from извл Left JOIN вн ON извл.customer=вн.customer Where вн.customer IS NULL;
The result is not what I want
Result os SQL