加入子查询不起作用"Alias Issue" -Postgres



我必须在Postgres中加入两个子查询我正在写下面的查询;

(select email, name from testing) AS  x
join 
(select distinct email from testing) AS y 
on x.email=y.email

它给我错误:

ERROR:在"AS"处或附近有语法错误第2行:(select email, name from testing) AS x

你在找这个吗?

select *
from (
select email, name 
from testing
) AS  x 
join (
select distinct email 
from testing
) AS y on x.email = y.email

可以简化为:

select x.email, x.name, y.email
from testing as x
join (
select distinct email from testing
) AS y on x.email = y.email

最新更新