2021 Jan 26 11:17 AM
Hi,
I have two different CDS views and I would like to join them. However, they have no common key on which I would like to join them. I would simply like to have the two tables in one CDS view, without changing any of the data or fields.
To visualuze my struggle: I have table A and B, and would like to get the code to come to the OUTCOME table:
Anyone who can help?
Thanks
2021 Jan 26 11:33 AM
Hello nielsvisser98
SELECT a1 AS a1, a2 AS a2, a3 AS a3, '' AS b1, '' AS b2, '' AS b3
FROM table_A
UNION
SELECT '' AS a1, '' AS a2, '' AS a3, b1 AS b1, b2 AS b2, b3 AS b3
FROM table_B
Kind regards,
Mateusz2021 Jan 26 11:33 AM
Hello nielsvisser98
SELECT a1 AS a1, a2 AS a2, a3 AS a3, '' AS b1, '' AS b2, '' AS b3
FROM table_A
UNION
SELECT '' AS a1, '' AS a2, '' AS a3, b1 AS b1, b2 AS b2, b3 AS b3
FROM table_B
Kind regards,
Mateusz2021 Jan 26 11:37 AM
Hi!
I believe you should be able to accomplish this with UNION. Here's the documentation.
The sets you UNION need to have the same structure, but I suppose it would be possible to "fake" that by selecting empty fields as B1, B2 and B3 for the table A select and vice versa.
2021 Jan 26 11:38 AM
Hah, mateuszadamus beat me to it. I'll leave my answer here with the link to the documentation... 🙂