>DEar Experts,
>
>I have three tables
>Customer, Ledger, Inventory
>
>In the Cust_Code of Inventory table some times stores customer code or
>Ledger code or some times empty(cash purchase).
>
>My purpose is while taking the report, if the cust_code is not empty i want to
>retrieve customer name from Custome Or ledger name from Ledger based on the
>value stored in the cust_code. how i will do that
>pls help me.
>
>Regards
>Abdulla
You can try something like this;
SELECT NVL(CU.Name,"") AS CustName, NVL(LD.Name,"") AS LedgerName, IIF(EMPTY(IN.Cust_code,"Cash Sale","") AS CashSale, IN.* ;
FROM Inventory IN ;
LEFT JOIN Customer CU ON IN.Cust_Code = CU.Cust_Code ;
LEFT JOIN Ledger LD ON IN.Cust_Code = LD.Cust_Code ;
INTO CURSOR MyResult
This is off the top of my head and has not been tested so you need to some debugging.