现在的位置: 首页 > 综合 > 正文

一个数据库小题目

2012年12月09日 ⁄ 综合 ⁄ 共 393字 ⁄ 字号 评论关闭

写SQL,学生表student(studentid,name)

绩表score(scoreid,studentid,score)

求出平均成绩大于60 且 至少有两门成绩高于70分的学生的编号和姓名

/*
学生表student(studentid,name)
绩表score(scoreid,studentid,score)
求出平均成绩大于60 且 至少有两门成绩高于70分的学生的编号和姓名
*/
select studentid, name 
from student 
where studentid in
(
select studentid
from score
where studentid in (select studentid from score where  score>65  group by studentid  having count(studentid)>=2 )
group by studentid
having avg(score)>60 
)

抱歉!评论已关闭.