因为submit_month最后一个是“2021汇总”,简单的依据date_format(submit_time,"%Y%m")分组是行不通的。下面的方法可行: select coalesce(t.sm,'2021汇总') submit_month, month_q_cnt, avg_day_q_cnt from (select date_format(submit_time,"%Y%m") sm, count(*) as month_q_cnt, round(count(*) / max(day(last_day(submit_time))),3) as avg_day_q_cnt from practice_record where date_format(submit_time,"%Y") = 2021 and score is not null group by date_format(submit_time,"%Y%m") with rollup ) t
1

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务