题解 | #截至当月的练题情况#

截至当月的练题情况

https://www.nowcoder.com/practice/80ed62a097564fad880b967678e460fc

select device_id,ym
,sum(question_cnt) over(partition by device_id order by ym) as sum_cnt -- 截至当月的每人练题总数
,round(sum(question_cnt) over(partition by device_id order by ym rows 2 preceding)/count(ym) over(partition by device_id order by ym rows 2 preceding),2) as avg3_cnt
,sum(question_cnt)over(order by ym) as total_cnt -- 截至当月所有人的练题总数
from (select device_id,date_format(event_date,'%Y-%m') as ym,
    count(question_id) as question_cnt
from question_practice_detail
group by device_id,ym
) m group by device_id,ym
order by device_id,ym

全部评论

相关推荐

昨天 12:33
安徽大学 Java
点赞 评论 收藏
分享
frutiger:逆天,我家就安阳的,这hr咋能说3k的,你送外卖不比这工资高得多?还说大厂来的6k,打发叫花子的呢?这hr是怎么做到说昧良心的话的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务