本题思路 主要问题是在时间的处理, date_format(date, '%Y-%m')可以取出年月,而year(date) 和month(date)可以分别取出年、月方便join是过滤 select a.job as job, a.day as first_year_mon, a.cnt as first_year_cnt, b.day as second_year_mon, b.cnt as second_year_cnt from ( select a.job as job, a.day as day, a.y as y, ...