我有一个语法错误,我不知道如何解决。我是MySQL的新手,错误消息让我感到困惑。
Select dept_name, total_student, total_instuctor, total_course
From department as d
natural left join ( select dept_name count( dept_name ) as total_student
from student
group by dept_name) as s
natural left join ( select dept_name count( dept_name ) as total_instructor
from instructor
group by dept_name) as i
natural left join ( select dept_name count( dept_name ) as total_course
from course
group by dept_name) as c
Group By dept_name
Order By count( total_student ) desc;
当前收到错误消息“此服务器版本在此位置的选择无效,期望:'(',WITH”加下划线的选择是第一个。
答案 0 :(得分:0)
您忘记了子查询中所有的,
选择项:
Select dept_name, total_student, total_instuctor, total_course
From department as d
natural left join ( select dept_name, count( dept_name ) as total_student
from student
group by dept_name) as s
natural left join ( select dept_name, count( dept_name ) as total_instructor
from instructor
group by dept_name) as i
natural left join ( select dept_name, count( dept_name ) as total_course
from course
group by dept_name) as c
Group By dept_name
Order By count( total_student ) desc;