项目描述
上传时间
浏览人数
# 1.查询学生选课表中的全部数据
select * from student_info;
# 2.查询计算机系学生的姓名、年龄
select name,age from student_info where faculty = '计算机';
# 3.查询成绩在70﹏80分之间的学生的学号、课程号和成绩
select id,classnum,grade from student_info where grade between 70 and 80;
# 4.查询计算机系年龄在18﹏20之间且性别为“男”的学生的姓名和年龄
select name,age from student_info where sex = '男' and age between 18 and 20 and faculty = '计算机';
# 5.查询课程号为“c01”的课程的最高分数
select max(grade) from student_info where classnum = 1;
# 6.查询计算机系学生的最大年龄和最小年龄
select max(age),min(age) from student_info where faculty = '计算机';
# 7.统计每个系的学生人数
select faculty,count(id) from student_info group by faculty;
# 8.统计每门课程的选课人数和考试最高分
select class,count(id),max(grade) from student_info group by class;
# 9.将计算机系的成绩按降序显示结果
select * from student_info where faculty = '计算机' order by grade desc;
# 10.查询选修了课程“c02”的学生的姓名和所在系
select name,faculty from student_info where classnum = 2;
# 11.查询成绩在80分以上的学生的姓名、课程号和成绩,并按成绩的降序排列结果
select name,classnum,grade from student_info where grade > 80 order by grade desc;
# 12.删除成绩小于50分的选课记录
set sql_safe_updates = 0; # 关闭安全模式
delete from student_info where grade < 50;
# 13.将所有选修了课程“C01”的学生的成绩加10分
update student_info set grade = grade + 10 where classnum = 1;
# 14.将计算机系所有选修了课程“计算机文化基础”课程的学生的成绩加10分
update student_info set grade = grade + 10 where class = '计算机文化基础' and faculty = '计算机';