当前位置:网站首页>[SQL] sql22 counts the number of salary records of each department
[SQL] sql22 counts the number of salary records of each department
2022-04-21 21:05:00 【A research monk who doesn't like research】
subject :
There is a department table departments A brief introduction is as follows :
| dept_no | dept_name |
| d001 | Marketing |
| d002 | Finance |
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 | 2001-06-22 | 9999-01-01 |
| 10002 | d001 | 1996-08-03 | 9999-01-01 |
| 10003 | d002 | 1996-08-03 | 9999-01-01 |
There's a payroll salaries A brief introduction is as follows :
| emp_no | salary | from_date | to_date |
| 10001 | 85097 | 2001-06-22 | 2002-06-22 |
| 10001 | 88958 | 2002-06-22 | 9999-01-01 |
| 10002 | 72527 | 1996-08-03 | 9999-01-01 |
| 10003 | 32323 | 1996-08-03 | 9999-01-01 |
Please count the salary records of each department , Give the department code dept_no、 Department name dept_name And the Department salaries How many records are there in the table sum, according to dept_no Ascending sort , The output of the above example is as follows :
| dept_no | dept_name | sum |
| d001 | Marketing | 3 |
| d002 | Finance | 1 |
Answer key :
After three tables are connected dept_no grouping , Calculation count
select
dp.dept_no,
ds.dept_name,
count(dp.dept_no)
from
dept_emp dp
left join
salaries s
on
dp.emp_no = s.emp_no
join
departments ds
on
dp.dept_no = ds.dept_no
group by
dp.dept_no
order by
dp.dept_no
版权声明
本文为[A research monk who doesn't like research]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212059008671.html
边栏推荐
- Complete collection of basic MySQL commands
- AttributeError: ‘list‘ object has no attribute ‘endswich‘
- 红日靶场--内网渗透练习
- vxworks学习
- 通达OA系统对接 单点登录平台使用和开发手册
- [embedded] about IAP + XMODEM receiving bin file from outside to upgrade the chip
- MapReduce服务初体验
- 电滑环对材质有什么要求
- AttributeError: ‘list‘ object has no attribute ‘endswich‘
- 工作流引擎 参数设置及业务引擎
猜你喜欢

Matlab handle graphics

《动手学机器人学》7.3.2动手学坐标变换 齐次矩阵生成(四元数+欧拉角)齐次坐标运算

The annual salary is 170W. Alibaba P8 blind date requires the woman's monthly salary of 10000. Netizen: it's a little high

《动手学机器人学》7.2.3姿态的多种表示,四元数,欧拉角旋转矩阵、轴角ROS2

Tag recognition based on Huawei cloud image

Fundamentals of reinforcement learning (I): multi armed bandit

OA表单设计 案例展示

Swift uses avplayer and avplayeritem for voice playback

Connection between Tongda OA and third-party app

Principal component analysis R language implementation
随机推荐
通达oa工作流升级 操作说明
通达OA表单会签意见样式
TGIP-CN 038 报名|深度解析 Apache Pulsar 源码阅读正确姿势(一)
25.<tag-数组和模拟>-lt- 31.下一个排列 + lt- 556. 下一个更大元素 III
培训管理系统操作说明
The annual salary is 170W. Alibaba P8 blind date requires the woman's monthly salary of 10000. Netizen: it's a little high
avformat_new_stream理解
AttributeError: ‘list‘ object has no attribute ‘endswich‘
滑环接线最主要的看什么
学生管理系统的架构文档
oracle列转行,拆分一个字段为多列
VxWorks learning
Weekly report from April 11, 2022 to April 17, 2022
824. Goat Latin
其它——ZeroRPC和SimpleXMLRPCServer
【常用英文单词】
Tag recognition based on Huawei cloud image
其它——MyCat实现分库分表
What is the most important aspect of slip ring wiring
工作流操作说明