+ Reply to Thread
Results 1 to 2 of 2

Thread: Combine 2 columns into 1 column using join

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    12

    Combine 2 columns into 1 column using join

    Hi , i am trying to use the join statment to combine two columns into 1 column.
    Let`s say i got two columns [FirstName and LastName]
    And i have table like that :
    Code:
    FirstName
    ==========
    Jack
    Barack  
    John 
    
    LastName
    ==========
    Chirac
    Obama 
    Candy
    And i want the table to be like that :
    Code:
     First      Last   
    =====================
     Jack       Chirac    
     Barack     Obama      
     John       Candy
    Any ideas ?
    Last edited by moie; 05-22-2012 at 02:46 PM.

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    27
    Here is the Join statment :
    Code:
    SELECT FirstName AS First, LastName AS Last
    FROM
    (
      SELECT ROW_NUMBER() OVER (ORDER BY ID) AS RowNum, FirstName
      FROM FirstName
    ) t1
    INNER JOIN
    (
      SELECT ROW_NUMBER() OVER (ORDER BY ID) AS RowNum, LastName
      FROM LastName
    ) t2
    ON t1.RowNum = t2.RowNum

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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