with t as (
select
(select t1 from table1 t1 limit 1) t,
'foo' x
)
select
t.id, t.code, x
from t
如何在结果查询中获取t.id和t.code? p>
答案 0 :(得分:2)
您需要在结果集中添加一个额外的括号。
我已将您的CTE重命名,以区分括号是指在CTE中选择的表,而不是CTE本身。
with cte as (
select
(select t1 from table1 t1 limit 1) t,
'foo' x
)
select
(t).id, (t).code, x
from cte