当前位置:网站首页>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
);
边栏推荐
- SQL Analysis of ShardingSphere
- The maximum quantity leetcode6133. Grouping (medium)
- Write a method to flatten an array and deduplicate and sort it incrementally
- 基于ProXmoX VE的虚拟化家庭服务器(篇一)—ProXmoX VE 安装及基础配置
- 56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)
- Basic Theoretical Knowledge of Software Testing - Use Cases
- Li Chi's work and life summary in July 2022
- typescript27-枚举类型呢
- leetcode6132. Make all elements in an array equal to zero (simple, weekly)
- 【愚公系列】2022年07月 .NET架构班 085-微服务专题 Abp vNext微服务网关
猜你喜欢
智芯传感输液泵压力传感器 为精准智能控制注入科技“强心剂”
button remove black frame
Unknown Bounded Array
Excel record of integer programming optimization model to solve the problem
How to promote new products online?
leetcode:126. Word Solitaire II
7月编程排行榜来啦!这次有何新变化?
时时刻刻保持敬畏之心
typescript23-tuple
[kali-information collection] enumeration - DNS enumeration: DNSenum, fierce
随机推荐
Input input box cursor automatically jumps to the last bug after the previous input
MySQL4
API设计笔记:pimpl技巧
UE4 rays flashed from mouse position detection
使用ts-node报错
请问shake数据库中想把源的db0的数据同步到目的db5,参数怎么设置呢?
Valentine's Day Romantic 3D Photo Wall [with source code]
In the shake database, I want to synchronize the data of the source db0 to the destination db5, how to set the parameters?
2022-07-31: Given a graph with n points and m directed edges, you can use magic to turn directed edges into undirected edges, such as directed edges from A to B, with a weight of 7.After casting the m
PMP 项目资源管理
Progressive Reconstruction of Visual Structure for Image Inpainting 论文笔记
TypeScript simplifies running ts-node
Basic Theoretical Knowledge of Software Testing - Use Cases
Mysql基础篇(Mysql数据类型)
Character encoding and floating point calculation precision loss problem
一个往年的朋友
2. # code comments
lambda
typescript25-类型断言
Game Theory (Depu) and Sun Tzu's Art of War (42/100)