当前位置:网站首页>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
);
边栏推荐
- 【愚公系列】2022年07月 Go教学课程 024-函数
- 【无标题】
- 请问表格储存中用sql只能查询到主键列,ots sql非主键不支持吗?
- The difference between scheduleWithFixedDelay and scheduleAtFixedRate
- Li Chi's work and life summary in July 2022
- 动态规划 01背包
- API Design Notes: The pimpl trick
- MLP neural network, GRNN neural network, SVM neural network and deep learning neural network compare and identify human health and non-health data
- 请问shake数据库中为什么读取100个collection 后,直接就退出了,不继续读了呢?
- 6-23漏洞利用-postgresql代码执行利用
猜你喜欢

Optional parameters typescript19 - object

使用ts-node报错

怀念故乡的面条

罗技鼠标体验记录

JS new fun(); class and instance JS is based on object language Can only act as a class by writing constructors

Message queue design based on mysql

最新 955 不加班的公司名单

数组问题之《下一个排列》、《旋转图像》以及二分查找之《搜索二维矩阵》

Difference Between Compiled and Interpreted Languages

这里有110+公开的专业数据集
随机推荐
Advice given by experts with four years of development experience in Flutter tutorial
PMP 项目资源管理
Basic Theoretical Knowledge of Software Testing - Use Cases
请问shake数据库中为什么读取100个collection 后,直接就退出了,不继续读了呢?
【愚公系列】2022年07月 .NET架构班 085-微服务专题 Abp vNext微服务网关
PMP 项目质量管理
一个往年的朋友
博客系统(完整版)
MySQL3
This article takes you to understand the past and present of Mimir, Grafana's latest open source project
typescript24 - type inference
MySQL4
【愚公系列】2022年07月 Go教学课程 023-Go容器之列表
Unknown Bounded Array
Interview Blitz 69: Is TCP Reliable?Why?
Make your Lottie support word wrapping in text fields
typescript21 - Comparison of Interfaces and Type Aliases
数组问题之《下一个排列》、《旋转图像》以及二分查找之《搜索二维矩阵》
Risk strategy important steps of tuning method
How to promote new products online?