题解 | #月总刷题数和日均刷题数#

月总刷题数和日均刷题数

http://www.nowcoder.com/practice/f6b4770f453d4163acc419e3d19e6746

select DATE_FORMAT(submit_time,"%Y%m") as submit_month, count(DISTINCT uid,question_id,submit_time) as month_q_cnt, round(count(DISTINCT uid,question_id,submit_time)/ DAYOFMONTH(LAST_DAY(DATE_FORMAT(submit_time,"%Y%m%d"))) ,3) as avg_day_q_cnt from practice_record where DATE_FORMAT(submit_time,"%Y") = 2021 group by DATE_FORMAT(submit_time,"%Y%m") union all SELECT '2021汇总' as submit_month, count(DISTINCT uid,question_id,submit_time) as month_q_cnt, round(count(DISTINCT uid,question_id,submit_time)/ DAYOFMONTH(LAST_DAY(DATE_FORMAT(submit_time,"%Y%m%d"))) ,3) as avg_day_q_cnt from practice_record where DATE_FORMAT(submit_time,"%Y") = 2021 group by DATE_FORMAT(submit_time,"%Y")

全部评论

相关推荐

已老实求offer😫:有点像徐坤(没有冒犯的意思哈)
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务