微信二维码
微博二维码
qq号二维码

数据库基础练习(一)

王伟平 2021.04.30 523人浏览
数据库基础哦~

#查询学生选课表中的全部数据

select * from student_info; 

#查询计算机系学生的姓名、年龄

select * from student_info where faculty = '土系';

#查询成绩在70﹏80分之间的学生的学号、课程号和成绩

select * from student_info where grade between 70 and 80;

#查询计算机系年龄在18﹏20之间且性别为“男”的学生的姓名和年龄

select age , sex from student_info where faculty = '土系' and sex = '男';

#查询课程号为“c01”的课程的最高分数

select max(grade) from student_info where classnum = 'c01';

#查询计算机系学生的最大年龄和最小年龄

select max(age),min(age),faculty = '火系'from student_info ;

#统计每个系的学生人数

select count(faculty),class from student_info group by class;

#统计每门课程的选课人数和考试最高分

select count(grade), max(grade), class class from student_info group by class; 

#将计算机系的成绩按降序显示结果

select * from student_info order by grade desc;

#查询选修了课程“c02”的学生的姓名和所在系

select * from student_info where classnum = 'c02';

#查询成绩在80分以上的学生的姓名、课程号和成绩,并按成绩的降序排列结果

select * from student_info where grade>80 order by grade desc; 

#删除成绩小于50分的选课记录

delete from student_info where grade < 50;

set sql_safe_updates = 0;

#13.将所有选修了课程“C01”的学生的成绩加10分

update student_info set grade = grade + 10 where classnum = 'c01';

#14.将计算机系所有选修了课程“计算机文化基础”课程的学生的成绩加10分

update student_info set grade = grade + 10 where faculty = '前端';


分享到:
天津UI设计培训-CleanPNG免抠素材网站
  • 2020.11.30
  • 2024什么价格?天津平面设计/UI设计师就业实录
  • 2024.03.20