我想知道是否可以加入我们正在创建的同一个表,而不必在加入后复制整个表代码。
例如:
create table tableC as
select *
from (
select *, min(a) as minA
from tableB
group by id) as tb0
)
join (select *, min(a) as minA
from tableB
where min(a) = 1) as tb1
on tb1.id = tb0.id;
在此示例中,加入不是必需的,但在某些情况下仍然是必需的。我的问题是我们可以使用第一个块代码中的表来执行连接,而不必在连接后复制整个代码吗?
更准确地说,我们可以做类似的事情
create table tableC as
select *
from (
select *, min(a) as minA
from tableB
group by id) as tb0
)
join (select *
from **tb0**
where **minA** = 1) as tb1
on tb1.id = tb0.id;
谢谢