SELECT ; IIF( ISNULL(tCredit.cust_id1), tDebit.cust_id1, tCredit.cust_id1) AS cust_id1, ; IIF( ISNULL(tCredit.cust_id1), tDebit.cust_id2, tCredit.cust_id2) AS cust_id2, ; NVL(tDebit.amt, 0) AS Debitamt, NVL(tCredit.amt,0) AS Creditamt ; FROM tCredit ; FULL OUTER JOIN tDebit ON tCredit.cust_id1 = tDebit.cust_id1 ; AND tCredit.cust_id2 = tDebit.cust_id2 ; INTO CURSOR CredIDebit>I have two tables: tCredit and tDebit. Each has three fields: cust_id1, cust_id2, amt. Want to produce a table that has cust_id1, cust_id2, credit_amt, debit_amt.