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

截至当月的练题情况

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

全部评论

相关推荐

牛客593440405号:换张照片,hr看了怕你死在工位上
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务