思路
实习广场投递简历分析(三)
http://www.nowcoder.com/questionTerminal/83f84aa5c32b4cf5a75558d02dd7743c
思路分享:
首先查找2026年的简历投递情况->查找2025年的简历投递情况->上述两查询结果以job和月份进行内联结->从内联结表中获取所有信息
step1-2: 查找2026/2025年的简历投递情况:
select job,date,date_format(date,'%Y-%m') as second_year_mon,sum(num) as second_year_cnt from resume_info where date like '2026%' group by job,second_year_mon
step2:上述两查询结果以job和月份进行内联结
( select job,date,date_format(date,'%Y-%m') as second_year_mon,sum(num) as second_year_cnt from resume_info where date like '2026%' group by job,second_year_mon )as tmp2 inner join ( select job,date,date_format(date,'%Y-%m') as second_year_mon,sum(num) as second_year_cnt from resume_info where date like '2025%' group by job,second_year_mon ) as tmp on tmp.job = tmp2.job and date_format(tmp.date,'%m') = date_format(tmp2.date,'%m')
step3:查询最终结果
select tmp.job,first_year_mon,first_year_cnt,second_year_mon ,second_year_cnt ( select job,date,date_format(date,'%Y-%m') as second_year_mon,sum(num) as second_year_cnt from resume_info where date like '2026%' group by job,second_year_mon )as tmp2 inner join ( select job,date,date_format(date,'%Y-%m') as second_year_mon,sum(num) as second_year_cnt from resume_info where date like '2025%' group by job,second_year_mon ) as tmp on tmp.job = tmp2.job and date_format(tmp.date,'%m') = date_format(tmp2.date,'%m') order by tmp.first_year_mon DESC,tmp.job DESC