表结构没有?什么数据库也没说,我用access的语法吧
我假设个表结构吧
学生表:学号 姓名 性别 年龄 所在院系 班级 入学日期
选课表:学期 学号 课程号 成绩
课程表:课程号 课程名 是否必修
1 select * from 学生表 where 学号 in (select top 1 学号 from (select top 1 学号, sum(成绩) as 总成绩 from 选课表 where 学期 = 'XX' group by 学期, 学号) order by 总成绩)
2 问题不明确,表S是?每一年龄组是什么?
3 select * from 学生表 where 学号 in (select 学号 from 选课表 group by 学号, 课程号 having count(*) = (select count(*) from 课程表 where 是否必修 = '否'))
4 select * from 学生表 where 学号 in (select 学号 from (select a.学号, a.课程号 from 选课表 a, 课程表 b where a.课程号=b.课程号 and b.学号='20026001') group by 学号 having count(*) = (select count(*) from 选课表 where 学号='20026001')))