create table result as
(
select department.Dcode as de_code, department.Dname as de_name
from (department join enroll on department.Dcode = enroll.Dcode)
);
SELECT result.de_name,
COUNT(result.de_name) AS occurr
FROM result
GROUP BY result.de_name
ORDER BY occurr DESC
LIMIT 1;
drop table result;
答案 0 :(得分:0)
你可以试试这个:
SELECT result.de_name, COUNT(result.de_name) AS occurr
FROM
(select department.Dcode as de_code, department.Dname as de_name from department join enroll on department.Dcode = enroll.Dcode) as result
GROUP BY result.de_name
ORDER BY occurr DESC
此处result
是INNER JOIN
返回的记录的别名。