创建学生表student,成绩表sc,课程表course
create or replace table student(
sid int(11) primary key not null,
sname char(25) not null,
age int(11) not null,
sex char(2) not null,
department char(40) ,
address char(200) ,
birthplace varchar(256)
);
create or replace table sc(
sid int(11) not null,
cid int(11) not null,
grade int(11)
);
create or replace table course(
cid int(11) not null primary key default 4,
cname char(40),
teacher char(40)
);
#以下是插入课程表的数据
delete from course ;
insert into course values('8108001','math','sandy');
insert into course values('8108002','english','sherry');
insert into course values('8108003','computer','sandy');
insert into course values('8108004','web','sandy');
insert into course values('8108005','java','sandy');
insert into course values('8108006','C languge','sherry');
insert into course values('8108007','python','xiaozhu');
insert into course values('8108008','testing','xiaozhu');
insert into course values('8108009','linux','sherry');
insert into course values('8108010','shell','sherry');
#右联结插入数据----begin
insert into course values('8108020','shell','sherry');
insert into course values('8108021','shell','sherry');
insert into course values('8108022','shell','sherry');
insert into course values('8108023','shell','sherry');
insert into course values('8108024','shell','sherry');
#----end
#以下是插入成绩级表的数据
delete from sc;
insert into sc values('3108001','8108010','90');
insert into sc values('3108001','8108003','67');
insert into sc values('3108002','8108003','54');
insert into sc values('3108002','8108010','84');
insert into sc values('3108003','8108003','78');
insert into sc values('3108004','8108004','89');
insert into sc values('3108005','8108006','56');
insert into sc values('3108006','8108005','60');
insert into sc values('3108007','8108004','79');
insert into sc values('3108008','8108008','89');
insert into sc values('3108009','8108002','46');
insert into sc values('3108010','8108003','87');
insert into sc values('3108011','8108001','85');
insert into sc values('3108011','8108002','81');
insert into sc values('3108012','8108001','97');
insert into sc values('3108012','8108002','55');
insert into sc values('3108013','8108002','86');
insert into sc values('3108013','8108001','71');
insert into sc values('3108014','8108002','69');
insert into sc values('3108014','8108001','78');
insert into sc values('3108015','8108002','67');
insert into sc values('3108016','8108001','85');
#左联结插入的数据
insert into sc values('3108016','8108013','85');
insert into sc values('3108016','8108012','85');
insert into sc values('3108016','8108011','85');
insert into sc values('3108016','8108012','85');
insert into sc values('3108016','8108002','80');
insert into sc values('3108016','8108006','79');
insert into sc values('3108016','8108009','36');
insert into sc values('3108016','8108010','78');
insert into sc values('3108016','8108020','88');
insert into sc values('3108016','8108021','83');
insert into sc values('3108016','8108022','86');
insert into sc values('3108016','8108023','75');
insert into sc values('3108016','8108024','78');
#----end
#以下是插入学生信息数据
delete from student;
insert into student values('3108001','wang min',21,'f','computer-tec','zhongshan road','jiangsu');
insert into student values('3108002','jidu',20,'m','english','zhongshan road','fujian');
insert into student values('3108003','wangqing',19,'f','computer-tec','zhongshan road','jiangsu');
insert into student values('3108004','liuxin',23,'f','chinese','zhongshan road','shanghai');
insert into student values('3108005','ligu',22,'f','computer-tec','zhongshan road','jiangsu');
insert into student values('3108006','songjia',19,'m','english','zhongshan road','jiangsu');
insert into student values('3108007','huamao',20,'f','chinese','zhongshan road','shanghai');
insert into student values('3108008','zhujiao',21,'f','english','zhongshan road','jiangsu');
insert into student values('3108009','wuyi',23,'m','computer-tec','zhongshan road','jiangsu');
insert into student values('3108010','jilian',18,'f','chinese','zhongshan road','hunan');
insert into student values('3108011','linbiao',22,'m','computer-tec','zhongshan road','jiangsu');
insert into student values('3108012','maoguai',21,'m','english','zhongshan road','fujian');
insert into student values('3108013','rongqi',23,'m','computer-tec','zhongshan road','jiangsu');
insert into student values('3108014','sangzi',20,'f','chinese','zhongshan road','hunan');
insert into student values('3108015','surui',16,'f','computer-tec','zhongshan road','fujian');
insert into student values('3108016','liushaoqi',24,'m','english','zhongshan road','hunan');
练习题
- sandy老师所教的课程号、课程名称;
- 年龄大于20岁的女学生的学号和姓名;
- 在学生表中按性别排序,且男在前女在后显示记录。
- “wuyi”所选修的全部课程名称;
- 所有成绩都在80分以上的学生姓名及所在系;
- 没有选修“english”课的学生的姓名;
- 与“jilian”同乡的男生姓名及所在系;
- 英语成绩比数学成绩好的学生;
- 选修同一门课程时,女生比所有男生成绩都好的学生名单;
- 至少选修两门及以上课程的学生姓名、性别;
- 选修了sandy老师所讲课程的学生人数;
- 所讲课程的学生;
- 本校学生中有学生姓名/性别重复的同学,请编写脚本查出本校所有学生的信息,显示学号,姓名,性别,总成绩,对于姓名/性别重复的学生信息只取总成绩最高的那一条记录。
- “english”课程得最高分的学生姓名、性别、所在系;
- 新建一个表‘dt’,格式如下:
year1 | mon | account |
---|
达到效果如下:
处理前的数据:
year1 | mon | account |
---|---|---|
1991 | 1 | 1.1 |
1991 | 2 | 1.2 |
1991 | 3 | 1.3 |
1991 | 4 | 1.4 |
1992 | 1 | 2.1 |
1992 | 2 | 2.2 |
1992 | 3 | 2.3 |
1992 | 4 | 2.4 |
处理后的数据: year1 |
m1 | m2 | m3 | m4 |
---|---|---|---|---|
1991 | 1.10... | 1.20... | 1.29... | 1.39999997... |
1992 | 2.09... | 2.20... | 2.29... | 2.40000009... |
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦