SQL201二刷

查找薪水记录超过15条的员工号emp_no以及其对应的记录次数t

https://www.nowcoder.com/practice/6d4a4cff1d58495182f536c548fee1ae

/*select 
distinct c.emp_no
,count(c.emp_no)

from
(select
emp_no
,year(from_date)
,salary 现有工资
,lag(salary,1)over(partition by emp_no order by from_date) 上年工资
,(salary-lag(salary,1)over(partition by emp_no order by from_date)) 涨幅
from salaries) as c
where 涨幅 >0 and 涨幅 is not null
group by c.emp_no

*/






with cnt1 as
(
select
emp_no
,count(salary) as cnt 
from salaries
group by emp_no 
)

select 
emp_no
,cnt as t
from cnt1
where cnt>15



















全部评论

相关推荐

水墨不写bug:疑似没有上过大学
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务