题解 | 统计各个部门的工资记录数

with tmp as (
select t.*,s.salary
from (
select t2.emp_no,t2.dept_no,t1.dept_name
from departments as t1
inner join dept_emp as t2 on t1.dept_no = t2.dept_no) as t
inner join salaries as s on t.emp_no = s.emp_no)

select dept_no,dept_name,count(*) as sum
from tmp
group by dept_no,dept_name
order by dept_no asc;

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务