满意答案
Ties丿小锦
2015.05.10
采纳率:47% 等级:8
已帮助:166人
12345678910111213141516171819202122232425262728293031323334353637 --⑴ 张鹏同学不及格的那些课程名,以及这些课程的分数、任课教师 select Cn,Score,TEACHER from C join ( select C# ,score from SC where S# = (select S# from S where Sn='张鹏' ) ) T on C.C#=T.C# --⑵ 选了刘洋老师三门以上课程的学生的学号和姓名 select S#,Sn from S where S# in ( select S# from SC where C# in(select C# from C where TEACHER ='刘洋') group by S# having COUNT(*)>3 ) --⑶ 只有男生选的课程名称和教师——要求不用集合运算符 select Cn,TEACHER from C where C# not in ( select C# from SC where S# in(select S# from S where sex='女') ) --⑷ 全部女生都选了的课程名称 select C# from SC where S# in(select S# from S where sex='女') group by C# having COUNT(*)= (select COUNT(*) from S where sex='女') -- ⑸ 数据库课程分数低于平均的学生姓名和他的分数 select Cn,Score from C join ( select C#,Score from SC where C# =(select C# from C where Cn='数据库') and Score
是不是在最后加一个
where score>60
??
追答: 恩
select Cn,Score,TEACHER from C join
(
select C# ,score from SC
where S# = (select S# from S where Sn='张鹏' and score<60)
) T
on C.C#=T.C#
追问: 第一题能不能不用连接?
像这样:
select SC.Score, C.TEACHER, SC.CN
from SC, C
where C#=(select c# from s where c#=
( select c# from S Where Sn='张鹏' and score>60))
额,这个应该是错的吧。,,好像C#不在S中
追答: 难道我第一题用的不是连接?
00分享举报