14,927,597 members
See more:
SQL
```SELECT LM.eCPPatientDMG_Key FROM tbl_eCPLedger_Master  LM

WHERE LM.eCPLedger_Payer_Key  IN

(SELECT LP.eCPLedger_Payer_Key FROM tbl_eCPLedger_Payer LP WHERE UPPER(LP.eCPLedger_Payer_ID) = 'SELF' )and   LM.eCPAccount_Key='0481843194'

AND LM.eCPLedger_Payer_Key NOT IN

(SELECT LM1.eCPPatientDMG_Key FROM tbl_eCPLedger_Master LM1

WHERE LM1.eCPLedger_Payer_Key IN

(SELECT LP1.eCPLedger_Payer_Key FROM tbl_eCPLedger_Payer LP1 WHERE UPPER(LP1.eCPLedger_Payer_ID) <> 'SELF' )and   LM1.eCPAccount_Key='0481843194')```
Posted
Updated 9-Jun-15 21:05pm
v3
Maciej Los 10-Jun-15 5:14am

Do not empty a question when exists at minimum one answer! Respect the rules!

## Solution 1

Tr this:
SQL
```SELECT LM.eCPPatientDMG_Key
FROM tbl_eCPLedger_Master LM INNER JOIN tbl_eCPLedger_Payer LP ON  LM.eCPLedger_Payer_Key = LP.eCPLedger_Payer_Key
WHERE UPPER(LP.eCPLedger_Payer_ID) = 'SELF' and LM.eCPAccount_Key='0481843194'```

It should do the work!

Here is a very interesting article which shows the differences between joins: Visual Representation of SQL Joins[^]
v2