mysql各个部门的平均薪水
时间: 2023-08-26 14:18:16 浏览: 170
根据提供的引用内容,可以使用以下SQL查询语句来获取mysql各个部门的平均薪水:
SELECT d.dept_no, d.dept_name, AVG(s.salary) as average_salary
FROM departments d
JOIN dept_emp de ON d.dept_no = de.dept_no
JOIN salaries s ON de.emp_no = s.emp_no
GROUP BY d.dept_no, d.dept_name
ORDER BY d.dept_no;
该查询语句会连接departments、dept_emp和salaries三个表,通过dept_no来关联数据,然后计算每个部门的平均薪水,并按照部门编号升序排序。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [SQL练习:查询各个部门中工资高于本部门的平均工资的员工数和部门号,并按部门号排序](https://blog.csdn.net/weixin_46250898/article/details/114241092)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [MySQL——习题:统计各个部门的工资记录数](https://blog.csdn.net/qq_43790137/article/details/116029751)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文