Teradata SQL - Appending similar columns from 3 separate tables

General

Teradata SQL - Appending similar columns from 3 separate tables

I'm new to both SQL and Teradata. I have 3 tables with similar data that I need to append. There is no common field for which to join the tables together. I just want to take a column from table A and append similar columns from tables B and C to it. See the example below:

Table A contains columns First_Name_1 and Last_Name_1.

Table B contains columns First_Name_2 and Last_Name_2.

Table C contains columns First_Name_3 and Last_Name_3.

I want to combine the 3 tables so that First_Name_1 is in the same column as First_Name_2 and First_Name_3. Repeat  for Last_Name columns.

1 REPLY

Re: Teradata SQL - Appending similar columns from 3 separate tables

Select cast (First_Name_1 as varchar (255)) as First_Name ,  cast (Last_Name_1 as varchar (255)) as Last_Name from TableA

union

Select First_Name_2 as First_Name, Last_Name_2  as Last_Name from TableB

union

Select First_Name_3 as First_Name , Last_Name_3 as Last_Name from TableC;