SQL题
1.表结构如下
student (id, name,sex…)
course(id, name)
sc (id, s_id, c_id…)
查询选了两门课的学生的姓名
(两种方法,使用子查询或者group)
select student.name
from student
where student.id in
(select s_id
from sc
group by s_id
having count(s_id)>2)
2.表结构(字节面试题)
Student(id, name)
Course(id, name)
Score(id,s_id,c_id,score)
找出所修课程中全部大于80分的学生姓名
select name
from Student
where Student.id not in
(select distinct s_id
from Score
where score<=80)