Okay,

My SQL knowledge is limited to simple selects, so I'm going to need some
help with this one.  The first part is easy:


(I hope email does not screw up the fowmatting too much)


SELECT ORDER_NO, SOLD_TO_CUST_ID, BILL_TO_CUST_ID, ORDER_GRP,

FROM PS_ORD_HEADER 

WHERE ORDER_NO = 'OE-1062283'


Easy enough.  BUT, I now need to join customer names to these customer
id's.  Orders are stored in PS_ORD_HEADER and Customers are stored in
PS_CUSTOMER. Trouble is, I need to pull the customer name (NAME1) from
the same table TWICE in the same query based once on the SOLD_TO_ID and
then again on the BILL_TO_ID.

I've aded the (1) and (2) to distinguish between the two, knowing that
it's not correct SQL syntax, but just to show the logic.


SELECT 
        A.ORDER_NO, 
        A.SOLD_TO_CUST_ID, 
        B.NAME1(1), 
        A.BILL_TO_CUST_ID, 
        B.NAME1(2),
        A.ORDER_GRP,
FROM 
        PS_ORD_HEADER A, 
        PS_CUSTOMER B
WHERE 
        A.ORDER_NO = 'OE-1062283'
        AND 
        ?? A.SOLD_TO_CUST_ID = B.CUST_ID ??


I have no idea how to pull one field from the same record twice in the
same query based on two separate key fields for two separate results.

Phew.... I hope that made sense.

Casey

____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to