题解 | #月总刷题数和日均刷题数#主要是求每个月总有多少天
月总刷题数和日均刷题数
http://www.nowcoder.com/practice/f6b4770f453d4163acc419e3d19e6746
select * from ( select date_format(submit_time,'%Y%m') as submit_month, count(1) as month_q_cnt, round(count(1)/max(day(last_day(date_format(submit_time,'%Y%m%d')))),3) as avg_day_q_cnt from practice_record where year(submit_time) = 2021 group by date_format(submit_time,'%Y%m') union all select '2021汇总' as submit_month, count(1) as month_q_cnt, round(count(1)/31,3) as avg_day_q_cnt from practice_record where year(submit_time) = 2021 ) t order by submit_month