当前位置:网站首页>MySQL Niuke brush questions
MySQL Niuke brush questions
2022-06-22 06:26:00 【Begin to change】
One 、SQL21 Find the salary increase of active employees since their employment
1、 subject

2、 Ideas
First, find the salary information of the employee when he / she first joined the company and save it in a temporary table , Then find the current salary status of the employee and save it in another table ; Finally, you can get the desired result by subtracting the salaries of the two
3、 Misinterpretation
You can see from the salary table that there are two salaries stored in it , And the result of subtraction is what we need ;
The salary table is adjusted according to emp_no grouping , Then use the salary to reduce the salary ( This is my first thought , In fact, it won't work ) In the previous exercise , What we can do is subtract from column to column ( That is, operations performed by different attributes of the table ) Cannot operate between attributes ; Therefore, it is necessary to separate the previous salary and the current salary into two tables , Then you can subtract ;
4、 operation
① Join two tables , The connection condition is employee number , But there is also a condition that the time should be equal , What you get in this way is the salary at the time of entry , The obtained table is the salary table at the time of employment ;
② Join two tables , The connection condition is employee number , But there is also a condition that the time should be ‘9999-01-01’, Because this represents the salary situation of on-the-job employees , That is, the salary table of current employees ;
③ In front, I got the salary table of the entry and the current salary table , If you subtract their salary, you get an increase
5、 Source code
select b.emp_no,(b.salary-a.salary) as growth
from
(select e.emp_no,s.salary
from employees e left join salaries s
on e.emp_no = s.emp_no
and e.hire_date=s.from_date)a
inner join
(
select e.emp_no,s.salary
from employees e left join salaries s on e.emp_no = s.emp_no
where s.to_date = '9999-01-01'
)b
on a.emp_no=b.emp_no
order by growth边栏推荐
- tab[i = (n - 1) & hash] 的详细解读
- Expert system clips from introduction to mastery (I) introduction and overview of clips
- 【M32】单片机 svn 设置忽略文件
- 【OpenAirInterface5g】ITTI消息收发机制
- 【OpenAirInterface5g】RRC NR解析(一)
- 线程池的七大参数及自定义线程池
- KV260的PMOD接口介绍
- Huiding technology gr551x series development board supports openharmony
- 【OpenAirInterface5g】高层模块接口及itti实体线程创建
- Discrete PID control based on MATLAB
猜你喜欢

W800 chip platform enters openharmony backbone

Callable

Subqueries in sqlserver

Shengxin visualization (Part4) -- correlation diagram

SQL 注入漏洞(十)二次注入

SQL 注入漏洞(十一)宽字节注入

5G终端标识SUPI,SUCI及IMSI解析
![[PHP]TP6 CLI模式下创建tp6和多应用配置以及常见问题](/img/19/0a3319b04fe6449c90ade6f27fca4a.png)
[PHP]TP6 CLI模式下创建tp6和多应用配置以及常见问题

Configuration files required for SSM integration and error reports caused by common configuration errors

Research on automatic landing control system of carrier aircraft
随机推荐
[5g NR] mobile phone ID number IMEI and imeisv
【5G NR】UE注册管理状态
【5G NR】NG接口
IO intensive and CPU intensive
5G终端标识SUPI,SUCI及IMSI解析
C技能树评测——用户至上做精品
Class load memory analysis
import keras时遇到的错误 TypeError: Descriptors cannot not be created directly. If this call came from a _
SQL injection vulnerability (XIII) Base64 injection
[openairinterface5g] RRC NR resolution (I)
[5g NR] RRC connection reconstruction analysis
Stream流式计算
Modeling and Simulation of Radar Seeker Servo System
入门级测试Kotlin实现PopWindow弹窗代码
仙人掌之歌——进军To C直播(1)
MySQL-IFNULL处理N/A
【5G NR】NAS连接管理—CM状态
BlockingQueue四组API
[5g NR] ng setup of ngap protocol
W800 chip platform enters openharmony backbone