题目一:使用连接查询的方式,查询出各员工所在部门的人数与工程数,工程数命名为count_project。(连接3个表,并使用COUNT内置函数)
Create table employee(
Id int(3)primary key,
Name varchar(20),
Age int(1)
);
Create table department(
Rearch int(3),
Constraint foreign key(Rearch) references employee(id),
Sale int(3),
Constraint foreign key(Sale) references employee(id)
);
Create table project(
pid int(3),
Constraint foreign key(pid) references employee(id),
Number int(1)default 0
);
Empoyee
Id(primary key)
Name
age
001
Tom
25
002
Jack
18
003
Lucy
33
111
Marry
15
110
James
21
Department
Rearch(foreign key)
Sale(foreign key)
001
111
002
110
003
Project
PId(foreign key)
001
002
003
111
110
number(default 0)
2
3
1
0
5
insert into project(pid,number)values(001,2),(002,3),(003,1),(111,0),(110,5);
只能分俩步完成
第一步:select id,name,age,count(rearch),numberfrom employee,department,project where id in(select rearch from departmentwhere rearch=employee.id ) and id in(pid) group by id;
第二步:select id,name,age,count(sale),numberfrom employee,department,project where id in(select sale from department wheresale=employee.id ) and id in(pid) group by id
题目二:
在挑战实验1中构建的成绩管理系统中,物理老师想要找出分数最高的同学进行表扬,请你找出这个同学并把他的信息(id、姓名、性别)输出到路径 E盘 下的physics.txt文件中。同时 Tom 的化学成绩有异议,需要在原来的基础上加3分,请更新 Tom 的化学成绩。
导入导出操作在可视化软件进行