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

月总刷题数和日均刷题数

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

3个知识点: 1.天数的获得 day()与last_day结合使用 2.记得取余数round() 3.列数相同的的结果拼接 union all 4.对于出现的only_full_group_by 问题,加上any_value即可

count(submit_time) as month_q_cnt,
round(count(submit_time)/any_value(day(last_day(submit_time))),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(submit_time) as month_q_cnt,
round(count(submit_time)/31,3)
from practice_record
where year(submit_time)='2021'
order by submit_month
全部评论

相关推荐

找不到工作死了算了:没事的,雨英,hr肯主动告知结果已经超越大部分hr了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务