Hello, Folks
You may Have tried to Apply Union All betwenn two
CTEs.
For Example,
If you Have two Tables Named TableA and TableB
WITH CTE_TableA
AS
(
SELECT * FROM TableA
)
UNION ALL
WITH CTE_TableA
AS
(
SELECT * FROM TableA
)
Then Above SQL Statement Will be result into Error.
Now To Make Union Of Two CTEs, Follow Below Code Snippets,
WITH CTE_TableA
AS
(
SELECT * FROM TableA
),CTE_TableB
(
SELECT * FROM TableB
)
SELECT * FROM CTE_TableA
UNION ALL
SELECT * FROM CTE_TableB
Happy Coding !!!