题解 | #月总刷题数和日均刷题数#
月总刷题数和日均刷题数
https://www.nowcoder.com/practice/f6b4770f453d4163acc419e3d19e6746
select coalesce(year_mon,'2021汇总') as submit_month, count(question_id) as month_q_cnt, round(count(question_id)/max(t.days_month),3) as avg_day_cnt from (select question_id, dayofmonth(last_day(submit_time)) as days_month, date_format(submit_time,'%Y%m') as year_mon from practice_record where year(submit_time)=2021) as t group by t.year_mon with rollup;
我真的不明白,高赞的思路复制粘贴上去都是错的,是它出bug吗?这个答案也和我自己写的几乎一样,但是就报错,显示不出2021汇总,明明都是coalesce函数,真的搞不明白,头痛