题解 | #实习广场投递简历分析(三)#

实习广场投递简历分析(三)

https://www.nowcoder.com/practice/83f84aa5c32b4cf5a75558d02dd7743c


# 加max聚合函数的原因是因为再对2025和2026俩个表进行连接的时候,需要根据job和月份进行匹配,而我尝试用 
# month(a.mon)=month(b.mon)时,无法连接上数据,不到何原因,所以只能在a表和b表中添加一个max聚合函数来确定每
# 个月的最大日期,最后在连接时,可以用month()来匹配2025和2026对应的月份

select
a.job
,a.mon as first_year_mon
,a.cnt as first_year_cnt
,b.mon as second_year_mon
,b.cnt as second_year_cnt
from(
select
a.job
,date_format(a.date,'%Y-%m') as mon
,max(a.date) as "date"
,sum(a.num) as cnt
from resume_info a
where year(a.date)=2025
group by a.job,date_format(a.date,'%Y-%m')
) a
left join(
select
a.job
,date_format(a.date,'%Y-%m') as mon
,max(a.date) as "date"
,sum(a.num) as cnt
from resume_info a
where year(a.date)=2026
group by a.job,date_format(a.date,'%Y-%m')
) b
on a.job=b.job and month(a.date)=month(b.date)
order by first_year_mon desc,a.job desc
;


全部评论

相关推荐

哈哈哈哈哈哈哈哈哈哈这个世界太美好了
凉风落木楚山秋:毕业出路老师不管,你盖个章他好交差就完事了,等你盖完毕业了就不关他事情了
点赞 评论 收藏
分享
06-25 09:33
厦门大学 Java
程序员饺子:现在日常估计没啥hc了,等到八月多估计就慢慢有了。双九✌🏻不用焦虑的
投递快手等公司7个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-08 11:16
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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