Expanding on following question (Multiple Select Statement) I would like to know if I can do following:
WITH
cte1 as (
SELECT * from cdr.Location
),
cte2 as (
SELECT * from cdr.Location
WHERE cdr.Location.someField = cte1.SomeField
)
select * from cte1 union select * from cte2
So accent here is on following line:
WHERE cdr.Location.someField = cte1.SomeField
where within cte2 I'm referencing cte1 ?