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

月总刷题数和日均刷题数

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

select
    submit_month,
    cnt month_q_cnt,
    format (
        cnt / DAY (
            LAST_DAY (cast(concat (submit_month, '01') as date))
        ),
        3
    ) avg_day_q_cnt
from
    (
        select
            date_format (submit_time, '%Y%m') submit_month,
            count(id) cnt
        from
            practice_record
        where
            date_format (submit_time, '%Y') = '2021'
        group by
            date_format (submit_time, '%Y%m')
    ) a
    
union all
select
    '2021汇总' submit_month,
    cnt month_q_cnt,
    format (cnt / 31, 3) avg_day_q_cnt
from
    (
        select
            date_format (submit_time, '%Y') submit_month,
            count(id) cnt
        from
            practice_record
        where
            date_format (submit_time, '%Y') = '2021'
        group by
            date_format (submit_time, '%Y')
    ) a
order by submit_month

全部评论

相关推荐

10-28 11:04
已编辑
美团_后端实习生(实习员工)
一个2人:我说几个点吧,你的实习经历写的让人觉得毫无含金量,你没有挖掘你需求里的 亮点, 让人觉得你不仅打杂还摆烂。然后你的简历太长了🤣你这个实习经历看完,估计没几个人愿意接着看下去, sdk, 索引这种东西单拎出来说太顶真了兄弟,好好优化下简历吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务