面试之数据库

面试之数据库
sql

select b.name 年级名称,d.name 课程名称,count(*) 选课数量
from pe_student a,pe_grade b,pr_stu_elective c,pe_tch_course d
where a.fk_grade_id = b.id
and a.id=c.fk_stu_id
and c.fk_course_id=d.code
group by b.name,d.name;

select b.name 年级名称,count(*) 学生数量
from pe_student a,pe_grade b
where a.fk_grade_id = b.id
and a.id!=allselect fk_stu_id from pr_stu_elective)
group by b.name;

https://zhidao.baidu.com/question/1244266481518868739.html