2017-12-14 15 views
-1

파생 테이블에 별칭을 지정했지만 쿼리를 실행해도 "모든 파생 테이블에 자체 별칭이 있어야합니다."라는 오류가 표시됩니다.파생 테이블마다 고유 한 별칭이 있어야합니까? 어떻게 잘못 되었습니까?

select a,b,c,sum(d) as 'sum' 
from(select a,b,c,sum(d)as 'd' from e join f using(z)) as 'alias' 
group by a; 


EDIT: better sample 
----This gives derived table error----- 
select name,sum(pop) as 'total' from(select name as 'name',sum(population) 
as pop from table1 join table2 using(countrycode)); 

----This gives me the SQL syntax error-------- 
select name,sum(pop) as 'total' from(select name as 'name',sum(population) 
as pop from table1 join table2 using(countrycode)) as 'alias'; 

미리 감사드립니다.

+0

을 .... –

+0

당신이 [mcve]을 마련하려고 수 - 예를 들어, 사람들이 오류를 재현 할 수있게 해주는 간단한 스키마 정의? 현재 코드는 익명으로 처리되므로 문제의 위치를 ​​알 수 없습니다. – IMSoP

+0

@IMSoP done sher. – Supremo

답변

0

이 시도 : 유효한 MySQL의 쿼리 아닌

select name, 
     sum(pop) as `total` 
from( 
     select name as `name`, sum(population) as pop 
     from table1 
     join table2 using(countrycode) 
) `m` <---- alias needed here too