将xscjgl.sql文件内容导入xscjgl数据库,完成以下内容。
(1)查询学生的学号、姓名、出生时间。
select 学号,姓名,出生时间 from xs;
(2)查询1990年以后出生的学生的学号、姓名、出生时间。
select 学号,姓名,出生时间 from xs where 出生时间 >= '1990-01-01';
(3)按姓名升序显示学生的学号、姓名。
select 学号,姓名 from xs order by 姓名 asc;
(4)按专业名统计各专业的学生人数。
select 专业名,count(*) as 人数 from xs group by 专业名;
(5)查询姓“王”的学生的学号、姓名信息。
select 学号,姓名 from xs where 姓名 like '王%';
(6)查询学生的学号、姓名、课程名、成绩信息。
select a.学号,a.姓名,c.课程名,b.成绩 from xs a join xs_kc b on a.学号=b.学号 join kc c on b.课程号=c.课程号;
(7)统计学生的成绩总分并按总分由高到低排名。
select a.*,sum(成绩) 总分 from xs a join xs_kc b on a.学号=b.学号 group by 学号 order by 总分 desc;
(8)查询学生成绩总分高于200分的学生信息。
select a.*,sum(成绩) 总分 from xs a join xs_kc b on a.学号=b.学号 group by 学号 having 总分>=200;
(9)统计没有参加考试的学生名单。
select * from xs where 学号 not in (select 学号 from xs_kc);
(10)显示总分前三名的学生信息。
select a.*,sum(成绩) 总分 from xs a join xs_kc b on a.学号=b.学号 group by 学号 order by 总分 desc limit 0,3;
(11)查询参加计算机基础课程考试的学生成绩高于课程平均分的学生信息。
select a.学号,a.姓名 from xs a where a.学号 in (select b.学号 from xs_kc b where b.成绩>(select avg(成绩) from xs_kc b where b.课程号=(select c.课程号 from kc c where c.课程名='计算机基础')) and b.课程号=(select c.课程号 from kc c where c.课程名='计算机基础'));
(12)查询程序设计与语言课程最高分的学生的学号和姓名。
select a.学号,a.姓名 from xs a where a.学号=(select b.学号 from xs_kc b where b.成绩=(select max(成绩) from xs_kc b where b.课程号=(select c.课程号 from kc c where c.课程名='程序设计与语言')) and b.课程号=(select c.课程号 from kc c where c.课程名='程序设计与语言'));
(13)查询计算机基础、程序设计与语言和离散数学三门课程中最高分学生的学号、姓名、成绩。
以上内容仅供参考学习!