2021-02-05

数据表:

年级表:年级 id(主键),年级名称

create table grade(
id int not null primary key,
name char(10)
)engine=innodb default charset=utf8mb4;

成绩表:id(主键),学员编号,科目 id,分数,考试时间

create table score_card(
id int primary key,
stu_number char(10),
subjectid int,
score float,
time Date
)engine=innodb default charset=utf8mb4;

学生表:学生编号(主键),学生姓名,登录密码,性别,年级 id,电话, 地址,出生日期,email

create table student(
id int primary key,
name char(10),
password char(6),
sex char(2),
gradeid int,
phone char(11),
address varchar(50),
birthday Date,
email varchar(20)
)engine=innodb default charset=utf8mb4;

科目表:科目 id(主键),科目名称,学时,年级 id

create table subject(
id int primary key,
name char(20),
period float,
class_id int
)engine=innodb default charset=utf8mb4;

需求:

1. grade 表增加一个阶段,“就业期”

insert into grage values(1,’就业期’);

2.将第三阶段的学生的 gradeid 改为就业期的

update student a set grade_id=’4’where a grade_id=’3’;

3.查询所有得了 100 分的学号

select stu_number from grade where score=100;

4.查询所有 1989 年出生的学生(1989-1-1~1990-1-1)

select * from student where birthday between 1989-1-1 and 1990-1-1;

5.查询学生姓名为“金蝶”的全部信息

 
select * from student where name=’金蝶’;

6.查询 subjectid 为 8 的科目考试未及格(60 分)的学号和成绩

select stu_number,score from grade where grade_id=8 and score<60;

7.查询第 3 阶段课时大于 50 的课程全部信息新职课教研教学中心

select * from subject where class_id=3 and period>50;

8.查询 S1101001 学生的考试信息

select * from grade stu_number=’S1101001’;

9.查询所有第二阶段的女生信息

select * from student where id=2 and sex=’女’;

10.“基于.NET 平台的软件系统分层开发”需要多少课时

select period from subject where name=’基于.NET 平台的软件系统分层开发’;

11.查询“设计 MySchool 数据库”和“面向对象程序设计”的课时(使用 in)

select period from subject where name in(‘设计 MySchool 数据库’,’面向对象程序设计’);

12 查询所有地址在山东的学生信息

 select * from student where address=’山东’;

13 查询所有姓凌的单名同学

select * from student where name like ‘凌%’;

14.查询 gradeid 为 1 的学生信息,按出生日期升序排序

select * from student where gradeid=1 order by birthday ASC;

15.查询 subjectid 为 3 的考试的成绩信息,用降序排序

select * from grade where id=3 order by score DASC;

16.查询 gradeid 为 2 的课程中课时最多的课程信息

select * from subject where id=2 and peroid=(select max(peroid) from subject id=2);

17.查询北京的学生有多少个

select count(*) from student where address=’北京’;

18.查询有多少个科目学时小于 50

select count(*) from subject where subject<50;

19.查询 gradeid 为 2 的阶段总课时是多少

select sum(peroid) from subject where id=2;

20.查询 subjectid 为 8 的课程学生平均分


select avg(score) from grade where subjectidid=2;

21.查询 gradeid 为 3 的课程中最多的学时和最少的学时

select max(peroid),min(peroid) from subject where gradeid=3;

22.查询每个科目有多少人次考试

select subjectid,count(*) from score where time is not null order by subjectid;

23.每个阶段课程的平均课时

select id,avg(peroid) from object group by id;

24.查询每个阶段的男生和女生个数(group by 两列)

select id,sex,count(number) from student group by id,sex;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值