Reputation: 2457
Is it possible to access a table from a subquery?
Select d.table_c.*
from (with table_c as (select *
from table_a)
select *
from table_b
where table_a.id = table_b.id) as d
table_c is inside the subquery of d, I've tried to access it using d.table_c, but it doesn't seem to work.
Upvotes: 0
Views: 30
Reputation: 666
You cannot use CTE as subquery. But you can write like below.
;WITH table_c
as
(SELECT * FROM table_a)
SELECT *
from table_b b
INNER JOIN table_c c on c.id = b.id
Upvotes: 1