Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2010
    Posts
    38

    Unanswered: 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!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2010
    Posts
    38
    Thank you! Works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •