题解 | 每份试卷每月作答数和截止当月的作答总数。

select
    exam_id,
    date_format (start_time, '%Y%m') start_month,
    count(start_time) month_cnt,
    sum(count(start_time)) over (
        partition by
            exam_id
        order by
            date_format (start_time, '%Y%m') rows between unbounded preceding
            and current row
    ) cum_exam_cnt
from
    test.exam_record
group by
    exam_id,
    date_format (start_time, '%Y%m')

全部评论

相关推荐

04-21 11:22
已编辑
中华女子学院 UE4
点赞 评论 收藏
分享
牛客928043833号:在他心里你已经是他的员工了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务