找回密码
 立即注册
GZ_zousuisheng +好友
这个人很懒什么都没写
听众
1
主题
0
金钱
18
个人名片
粉丝关注
还没有人关注TA
添加表情

5-9作业

已有 162 次阅读2021-5-9 16:54

create table s1 (id int(10) primary key,name varchar(20),c int(10),s int(10),y int(10),class int(10));

insert into s1 values(1,"z1",90,75,88,1832),(2,"z2",72,59,68,1833),(3,"z3",97,85,98,1832),(4,"z4",91,78,52,1834),(5,"z5",66,75,28,1833),
(6,"z6",80,75,88,1832),(7,"z7",90,75,88,1834),(8,"z8",90,75,88,1834),(9,"z9",99,78,80,1834),(10,"z10",80,75,88,1832),
(11,"z11",90,75,88,183),(1,"z1",90,75,88,1832),(1,"z1",90,75,88,1832),(1,"z1",90,75,88,1832),(1,"z1",90,75,88,1832)

1、查询1832班的成绩信息
select * from s1 where class=1832;

2,查询1833班,语文成绩大于80小于90的成绩信息
select * from s1 where class=1833 and c between 80 and 90;

3,查询学生表中5到10行的数据
select * from s1 limit 4,6;

4,显示1832班英语成绩为98,数学成绩为77的姓名与学号,
select id ,name from s1 where class=1832 and y=98 and s=77;

5,查询出1832班成绩并且按语文成绩排序(降序)
select * from s1 where class=1833 order by c desc;

6,查询1833班与1832班,语文成绩与数学成绩都小于80的姓名。
select name from s1 where class in(1832,1833) and  c<80 and s<80  ;

7,查询出没有参加语文考试的学生姓名和班级名称。
select class ,name from s1  where c=0 or c is null

8,求出班上语文成绩不及格的学生姓名
select name from s1 where c<60;

9,求出每个班的数学平均成绩
select avg(s) s, class from s1 group by class;

10、求出每个班级语文成绩总分 --涉及到每个的时候都需要分组
select sum(c) c, class from s1 group by class;

11、将语文成绩不及格的学生成绩改为60分
update s1 set c=60 where c<60;

12、三科分数都大于70分的人名和年纪
select name, age from s1 where c>70 and s>70 and y>70;

13、求出英语分数高于70且其它任何一科目大于60分的人和班级
select name, class from s1 where y>70  and (c>60 or s>60);

14、统计每个班的人数
select count(id) from s1  group by class;

15、求每个班数学成绩大于80的人数
select count(*) num, class from s1 where s>80  group by class;

17、给student表增加3个字段(数据类型及长度自定义,建议要合理)
alter table s1 add age int(10),sex int(10),tall int(10);









全部作者的其他最新日志

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册