数据库单表作业
1、查询1832班的成绩信息
select class,chinese,english,math from student where class=1832;
2,查询1833班,语文成绩大于80小于90的成绩信息
select chinese,english,math from student where class = 1833 and chinese >80 and chinese <90;
3,查询学生表中5到10行的数据
select * from student limit4,6;
4,显示1832班英语成绩为98,数学成绩为77的姓名与学号
select name,sid from student where class=1832 and english=98 and math=77;
5,查询出1832班成绩并且按语文成绩排序(降序)
select chinese,english,math from student where class=1832 order by chinese desc;
6,查询1833班与1832班,语文成绩与数学成绩都小于80的姓名。
select name,from student class in(1832,1833)and chinese<80 and tach<80;
7,查询出没有参加语文考试的学生姓名和班级名称。
select name,class from student where chinese is null;
8,求出班上语文成绩不及格的学生姓名
select name from student where chinese<60;
9,求出每个班的数学平均成绩
select class,avg(math) from student group by class;
10、求出每个班级语文成绩总分 --涉及到每个的时候都需要分组
select class,sum(chinese) from student group by class;
11、将语文成绩不及格的学生成绩改为60分
alter table student change (select chinese from student where chinese<60;) 60;
12、三科分数都大于70分的人名和年纪
select name,age from student where chinese >70 and english>70 and math>70;
13、求出英语分数高于70且其它任何一科目大于60分的人和班级
select name,class from(select * from student where english>70)b where math>60 or chinese>60;
14、统计每个班的人数
select class, count() from student group by class;
15、求每个班数学成绩大于80的人数
select class,count() from student where math>80;
16、求出每个班英语成绩最高的那个人的姓名和班级名称--每个班英语成绩最高
select name,class from student group by class having max(english);
17、给student表增加3个字段(数据类型及长度自定义,建议要合理
alter table student add(sex int(10),heigt int(10),birth int(10));

浙公网安备 33010602011771号