Skip to main content
Solved

How to create a union Table in DSA

  • February 22, 2023
  • 4 replies
  • 201 views

ignacio
Contributor
Forum|alt.badge.img+1

I have the following code y DSA:

Select * from TableA 

union 

Select * from TableB

union 

Select * from Table C

I want to replace this code with a table

Best answer by Christian Hauggaard

Hi @ignacio 

This can be achieved by using a Junk Dimension table. If you add create a new table and add the mappings from each source table (i.e. TableA, TableB and TableC), you will see that you get duplicate records (i.e. UNION ALL). If you then right click on the new table, and under advanced, select “Add Junk Dimension Table” and then select the columns that you would like to include. Please see more info about Junk Dimensions here.

 

 

There are other ways to achieve this, such as creating a view with UNION statement (and then using a table insert to insert the data from the view into a table). Alternatively, Primary Keys could be used to ensure that records are not duplicated. Or a custom table insert could also be used.

 

View original
Did this topic help you find an answer to your question?

4 replies

Christian Hauggaard
Community Manager
Forum|alt.badge.img+5

Hi @ignacio 

This can be achieved by using a Junk Dimension table. If you add create a new table and add the mappings from each source table (i.e. TableA, TableB and TableC), you will see that you get duplicate records (i.e. UNION ALL). If you then right click on the new table, and under advanced, select “Add Junk Dimension Table” and then select the columns that you would like to include. Please see more info about Junk Dimensions here.

 

 

There are other ways to achieve this, such as creating a view with UNION statement (and then using a table insert to insert the data from the view into a table). Alternatively, Primary Keys could be used to ensure that records are not duplicated. Or a custom table insert could also be used.

 


rory.smith
TimeXtender Xpert
Forum|alt.badge.img+7
  • TimeXtender Xpert
  • 649 replies
  • February 23, 2023

Another alternative: map Table A, B, C into one table and use Advanced > Aggregate table to do a SELECT DISTINCT / GROUP BY to create unique records.

Personally I would always want to have the duplicates explicitly in staging as this may actually be a process or data-entry issue in the source systems that could be solved to everyone's benefit


Christian Hauggaard
Community Manager
Forum|alt.badge.img+5

@ignacio Has your question been answered? If so can you please help us by selecting and marking a best answer? Thanks :)

 


ignacio
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • 29 replies
  • March 2, 2023

I used customer Insert. 

Thanks for your help


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings