2017-12-14 1 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サー。 – 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 
関連する問題