Hmm, is there a way to use CTE and UNION together, so that I could refer to the CTEs from the UNION clauses?
something like this in sql:
WITH cte AS (
SELECT
*
FROM
shared
)
SELECT
cte.id,
f.x
FROM
cte
LEFT JOIN foo f ON f.id = c.id
UNION
SELECT
cte.id,
b.x
FROM
cte
LEFT JOIN bar b ON b.id = c.id;
ah, hmm, just using a map {:with ... :union [...]}
and referring to the cte's in the :union
by name seems to work
the dsl tripped me off a bit