Почему бы просто не превратить CTE в подзапросы?
SELECT ... -- your final logic goes here
FROM (
SELECT
a.[data] AS [Val1],
b.[data] AS [Val2],
(a.[data] + b.[data]) AS [Math]
FROM (SELECT 1 AS [data]) a
JOIN (SELECT 5 AS [data]) b ON 1=1
UNION ALL
SELECT
a.[data] AS [Val1],
b.[data] AS [Val2],
(a.[data] + b.[data]) AS [Math]
FROM (SELECT 3 AS [data]) a
JOIN (SELECT 8 AS [data]) b ON 1=1
) t
В противном случае вам необходимо сначала объявить все CTE, а затем использовать их в объединении. Это означает, что вы не можете использовать один и тот же псевдоним CTE дважды для двух разных запросов, поэтому:
WITH
[fu1] AS (SELECT 1 AS [data]),
[bar1] AS (SELECT 5 AS [data]),
[fu2] AS (SELECT 3 AS [data]),
[bar2] AS (SELECT 8 AS [data])
SELECT ... -- your final logic goes here
FROM (
SELECT
a.[data] AS [Val1],
b.[data] AS [Val2],
(a.[data] + b.[data]) AS [Math]
FROM [fu1] a
JOIN [bar1] b ON 1=1
UNION ALL
SELECT
a.[data] AS [Val1],
b.[data] AS [Val2],
(a.[data] + b.[data]) AS [Math]
FROM [fu2] a
JOIN [bar2] b ON 1=1
) t