SQL检索至少选修“程军”老师所授全部课程的学生姓名和成绩

2025-01-17 15:31:41
推荐回答(1个)
回答1:

select s.sname as 姓名,sc.grade as 分数
from s,sc
where s.sno=sc.sno --内链接
and s.sno in
(
select distinct(sc.cno)
from sc
where sc.cno in ( select s.no --所学的课程中一定要有程军老师教的课程
from s

where s.teacher='程军'

)

group by sc.sno

having count(sc.cno)>=(select count ( distinct s.no)--课程数大于等于程军老师所教课程数
from s

where s.teacher='程军‘

)

)

如果还有问题,请追问。
望采纳!