Click here to Skip to main content
14,927,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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')
Updated 9-Jun-15 21:05pm
Maciej Los 10-Jun-15 5:14am
Do not empty a question when exists at minimum one answer! Respect the rules!

1 solution

Tr this:
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!

I'd suggest to read about joins[^].
Here is a very interesting article which shows the differences between joins: Visual Representation of SQL Joins[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900