当前位置:网站首页>MySQL Niuke brush questions
MySQL Niuke brush questions
2022-06-23 07:14:00 【Begin to change】
Catalog
One 、 Get all non manager Employee salary , give dept_no、emp_no as well as salary
One 、 Get all non manager Employee salary , give dept_no、emp_no as well as salary
1、 subject
2、 Ideas
First, combine the employee information and salary into a table , The same is true of managers ;
Then connect the two tables , The connection condition is that the department number is the same , Finally, find the desired information from this large table , The precondition is that the employee's salary is greater than the manager's salary ;
The manager is also part of the staff , So the data in the first table contains the manager's data , But this doesn't affect the later results , Because what is needed is that the salary is greater than, it is excluded
If the condition is greater than or equal to , It is necessary to judge whether the employee number is in the manager table before establishing the employee salary table ;
3、 Source code
select b1.emp_no, manager_no, emp_salary, manager_salary
from(
select dept_no, de.emp_no, salary as emp_salary
from dept_emp as de
join salaries as s
on de.emp_no = s.emp_no
)as b1
join (
select dept_no, dm.emp_no as manager_no, salary as manager_salary
from dept_manager as dm
join salaries as s
on dm.emp_no = s.emp_no
)as b2
on b1.dept_no = b2.dept_no
where b1.emp_salary > b2.manager_salary
边栏推荐
猜你喜欢
随机推荐
‘latin-1‘ codec can‘t encode characters in position 103-115: Body (‘一串中文‘) is not valid Latin-1
Page embedded iframe click browser back problem
Regular expression graph and text ultra detailed summary without rote memorization (Part 1)
.h5文件忘记数据库名字,使用h5py打印
【AI实战】XGBRegressor模型加速训练,使用GPU秒级训练XGBRegressor
Mysql数据库的几个特点
在金融行业做数据产品经理是什么体验
Pspnet complete code implementation
deeplab v3 代码结构图
别找了诸位 【十二款超级好用的谷歌插件都在这】(确定不来看看?)
Learning and using quartz scheduling framework
NPM download error NPM err code error
Run typescript code directly using TS node
GloRe
MySQL(八) — 执行计划(Explain)详解
滚动播报效果的实现
Eureka
20220620 uniformly completely observable (UCO)
897. 递增顺序搜索树
406-双指针(27. 移除元素、977.有序数组的平方、15. 三数之和、18. 四数之和)









