This works perfectly! Thank you.
>>Invoice Table - Fields - CustomerNumber, City, State, County, Shiptokey
>>Shipto Table - Fields - ShiptoKey, City, State, County
>>
>>I need to be able to build an SQL statement that will give me the actual shipping address used on an invoice. If the order was shipped to the billto, there will not be a ShiptoKey in the Invoice Table for that record. If the order was shipped to a different shipping address, the ShiptoKey field will be populated and there will be a matching record in the Shipto Table file.
>>
>>I can make a join to pull BOTH addresses, but I want to make one that pulls only the actual shipping address regardless of wether a Shipto record was involved.
>>
>>Does that make sense?
>>
>>>Because of my Enghlish it is hard to me to understand what you want. But can you post some exmaples to see what can I do?
>
>
>What about:
>
>SELECT CustomerNumber, IIF(EMPTY(ShipToKey), City, ShipTo.City) AS City,;
> IIF(EMPTY(ShipToKey), State, ShipTo.State) AS State,;
> IIF(EMPTY(ShipToKey), County, ShipTo.County) AS County
> FROM Invoice;
> LEFT JOIN ShipTo ON Invoice.ShipToKey == ShipTo.ShipToKey;
> INTO CURSOR cInvoice
>
>
>
>Is this works for You?