我不知道如何通过子查询的列来group by
。
我要按language
分组,如下所示:
这是我的代码:
select a.name, count(a.language) as count
from
(select
temp2.name,
countrylanguage.language
from
countrylanguage
right join
temp2
on
temp2.code = countrylanguage.countrycode
) as a
group by a.language;
我得到了如下解决方案:
select temp2.name, count(countrylanguage.language)
from countrylanguage
join temp2 on temp2.code = countrylanguage.countrycode
group by temp2.name;
答案 0 :(得分:2)
您可以在下面尝试-不需要任何子查询
select temp2.name,count(countrylanguage.language)
from countrylanguage join temp2
on temp2.code = countrylanguage.countrycode
group by temp2.name
答案 1 :(得分:2)