If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Select values from same column with different names

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-01-10, 08:57
tosa tosa is offline
Registered User
 
Join Date: Feb 2010
Posts: 35
Select values from same column with different names

Hi!

I have tables Customer and SalesLine. SalesLine has OrderCustNumber, InvoiceCustNumber and DeliveryCustNumber which correspond to CustomerNumber in table Customer. I want to select CustomerName from table Customer. How do I select 3 values from column CustomerName?

I'm using a Progress database.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 04-01-10, 10:12
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,540
if progress supports sql similar to other databases, all you need to do is use three different joins to the customer table using table and column aliases
Code:
SELECT o.CustomerName AS order_customer
     , i.CustomerName AS invoice_customer
     , d.CustomerName AS delivery_customer
  FROM SalesLine
INNER
  JOIN Customer AS o
    ON o.CustomerNumber = SalesLine.OrderCustNumber
INNER
  JOIN Customer AS i
    ON i.CustomerNumber = SalesLine.InvoiceCustNumber
INNER
  JOIN Customer AS d
    ON d.CustomerNumber = SalesLine.DeliveryCustNumber
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-07-10, 01:24
tosa tosa is offline
Registered User
 
Join Date: Feb 2010
Posts: 35
Thank you! Works fine.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On