题解 | #实习广场投递简历分析(三)#
实习广场投递简历分析(三)
https://www.nowcoder.com/practice/83f84aa5c32b4cf5a75558d02dd7743c?tpId=82&tags=&title=&difficulty=0&judgeStatus=0&rp=1&sourceUrl=%2Fexam%2Foj%3Fpage%3D2%26tab%3DSQL%25E7%25AF%2587%26topicId%3D82
因为first_year_mon,second_year_mon已经不是date类型,所以不能用month(first_year_mon)=month(second_year_mon),可以用字符串截取函数substr或right,也可以先不对t1和t2表的日期转换格式,就可以用month函数了,最后再转换
select t1.job,first_year_mon,first_year_cnt,second_year_mon,second_year_cnt from
(select job,date_format(date,'%Y-%m')first_year_mon,sum(num)first_year_cnt
from resume_info where date like '2025%' group by job,first_year_mon)t1
join
(select job,date_format(date,'%Y-%m')second_year_mon,sum(num)second_year_cnt
from resume_info where date like '2026%' group by job,second_year_mon)t2
on t1.job=t2.job and substr(first_year_mon,6,7)=substr(second_year_mon,6,7)
order by first_year_mon desc,job desc
SQL题解 文章被收录于专栏
主要是为自己做个笔记