当前位置:网站首页>MySQL实践总结-
MySQL实践总结-
2022-08-01 04:39:00 【LXMXHJ】
文章目录
案例1:
已知信息
员工表 Employee
名称 | 类型 | 描述 |
---|---|---|
EmployeeId | Int | 员工id(唯一) |
Name | Varchar(50) | 员工姓名 |
Age | Int | 员工年龄 |
Varchar(50) | 员工邮箱 | |
Level | Int | 员工能级 |
工资表 salary
名称 | 类型 | 描述 |
---|---|---|
SalaryId | Int | 工资id(唯一) |
EmployeeId | Int | 员工id |
Money | Double | 工资金额 |
Date | Datetime | 发放日期 |
题目及解答
查询偶有员工的姓名和邮箱,并按照年龄降序、姓名升序排序。
select Name,Email
from Employee
order by Age asc,Name desc;
查询员工级别为1的所有员工的姓名及其对应的工资金额总和。
①select e.Name,s.Money
from Employee e
inner join Salary s
on e.EmployeeId = s.EmployeeId
where e.Level = 1
查询所有高于平均工资的工资发放信息以及对应的员工信息(发放日期、工资金额、员工id,员工姓名、员工年龄、员工邮箱、员工级别)
select s.Date,s.Money,s.EmployeeId,e.Name,e,Age,e.Email,e.Level
from Employee e
inner join Salary s
on e.EmployeeId = s.EmployeeId
where s.Money >(
select avg(Money)
from Salary
);
边栏推荐
- 项目风险管理必备内容总结
- Pyspark机器学习:向量及其常用操作
- High Numbers | 【Re-integration】Line Area Score 880 Examples
- Unity's primary method for implementing PlanarReflection under the BuildIn rendering pipeline
- Weekly Summary (*67): Why not dare to express an opinion
- typescript21-接口和类型别名的对比
- TIM登陆时提示00001(TIM00001)
- Game Theory (Depu) and Sun Tzu's Art of War (42/100)
- Input input box cursor automatically jumps to the last bug after the previous input
- PMP 相关方管理必背总结
猜你喜欢
Flutter "Hello world" program code
Pyspark机器学习:向量及其常用操作
typescript27-枚举类型呢
高数 | 【重积分】线面积分880例题
ICML2022 | Deep Dive into Permutation-Sensitive Graph Neural Networks
Hackers can how bad to what degree?
[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce
typescript23-tuple
typescript23-元组
【无标题】
随机推荐
数组问题之《两数之和》以及《三数之和 》
typescript25-类型断言
mysql中解决存储过程表名通过变量传递的方法
李迟2022年7月工作生活总结
Dynamic Programming 01 Backpack
【无标题】
typescript23-元组
typescript21-接口和类型别名的对比
Unknown Bounded Array
Flutter Tutorial 02 Introduction to Flutter Desktop Program Development Tutorial Run hello world (tutorial includes source code)
项目风险管理必备内容总结
API Design Notes: The pimpl trick
Immutable
Weekly Summary (*67): Why not dare to express an opinion
Excel record of integer programming optimization model to solve the problem
RSA主要攻击方法
UE4 模型OnClick事件不生效的两种原因
PMP 项目沟通管理
The maximum quantity leetcode6133. Grouping (medium)
Hackers can how bad to what degree?