当前位置:网站首页>[SQL] sql19 finds the last of all employees_ Name and first_ Name and corresponding Dept_ name
[SQL] sql19 finds the last of all employees_ Name and first_ Name and corresponding Dept_ name
2022-04-21 12:24:00 【A research monk who doesn't like research】
subject :
Find all employees last_name and first_name And corresponding dept_name_ Niuke Tiba _ Cattle from
There's an employee list employees A brief introduction is as follows :
| emp_no | birth_date | first_name | last_name | gender | hire_date |
| 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 |
| 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 |
| 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 |
| 10004 | 1954-05-01 | Chirstian | Koblick | M | 1986-12-01 |
There is a department table departments The table is summarized as follows :
| dept_no | dept_name |
| d001 | Marketing |
| d002 | Finance |
| d003 | Human Resources |
There is one , Department employee relations form dept_emp A brief introduction is as follows :
| emp_no | dept_no | from_date | to_date |
| 10001 | d001 | 1986-06-26 | 9999-01-01 |
| 10002 | d001 | 1996-08-03 | 9999-01-01 |
| 10003 | d002 | 1990-08-05 | 9999-01-01 |
Please find the of all employees last_name and first_name And corresponding dept_name, It also includes employees who have no assigned department for the time being , The output of the above example is as follows :
| last_name | first_name | dept_name |
| Facello | Georgi | Marketing |
| Simmel | Bezalel | Marketing |
| Bamford | Parto | Finance |
| Koblick | Chirstian | NULL |
Answer key :
Because employees without assigned department should also display , So take the employee table employees Subject to , You must output all the lines inside , Use it twice left join To connect three tables , The second time left join Is the last time left join The resulting temporary table is the same as the third table join.
select
e.last_name,
e.first_name,
ds.dept_name
from
employees e
left join
dept_emp dp
on
e.emp_no = dp.emp_no
left join
departments ds
on
dp.dept_no = ds.dept_no
版权声明
本文为[A research monk who doesn't like research]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211131571526.html
边栏推荐
- Anchor free new network: centernet and cornernet form centernet + +
- Chinese character extraction operation of Sao package (string, no re, in)
- LLVM之父ChrisLattner:编译器的黄金时代
- R语言中实现随机森林建模的包randomForest
- 去中心化VC平台CULTDAO发起对BetaMars项目投票,目前投票正在进行中
- DeFi借贷VS传统金融“无风险”利率产品
- [200 opencv routines by youcans] 159 Fixed threshold method for image processing
- Cultdao, a decentralized VC platform, launched a vote on the betamars project, which is currently in progress
- Vggnet neural network based on pytorch for flower recognition
- [software test series vi] software system test scheme
猜你喜欢

Machine learning-sklearn-13 (regression family - lower - nonlinear problem: polynomial regression (a new characteristic matrix is formed after polynomial transformation))

逆波兰表达式
![[dark horse morning post] Tao Hong paid 260 million dividends from Zhangting MLM company in three years; Yiling pharmaceutical replied to Lianhua Qingwen dispute: the case has been reported; Tencent v](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] Tao Hong paid 260 million dividends from Zhangting MLM company in three years; Yiling pharmaceutical replied to Lianhua Qingwen dispute: the case has been reported; Tencent v

Kubernetes service discovery monitoring apiserver

只出现一次的数字 II(哈希、位操作、逻辑电路、有限状态自动机)

Daily AI frontier terminology: active learning

Aaai2022 | unbiased temporal knowledge reasoning based on probabilistic soft logic

游戏行业实战案例2:玩家等级

骚包的中文字符提取操作(字符串,不用 re ,用 in )

伯克利、三星|一个快速的训练后变换器修剪框架
随机推荐
Teach you to easily solve CSRF Cross Site Request Forgery Attack
新技术又来了,拥抱AGP7.0,准备好告别Transform了吗?
一分钟教会您使用Yolov5训练自己的数据集并测试
a标签或者<router-link>使用target=“_blank“打开新页面,新页面的sessionStorage丢失
There is no market for virtual currency. Why can there be no small temptation for some people?
Kubernetes 服务发现 监控APIServer
[BSidesCF 2019]Kookie
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
龙智被评估为CMMI [3] 级
Couleurs du thème sublime
Is it difficult to choose binary version control tools? After reading this article, you will find the answer
《深度学习》学习笔记(七)
Title record of TIANTI competition (II)
Daily AI frontier terminology: active learning
DeFi借贷VS传统金融“无风险”利率产品
顶流“健身博主”刘畊宏
sublime主题配色
风丘科技为您提供10M以太网解决方案
jsapi 支付缺少appid
A tag or < router link > use target = "_blank" to open a new page, and the sessionstorage of the new page is lost