【大厂真题】SQL17题解 | 统计用户获得积分

# 需求分析  单个记录/10,向下取整
# 每个人,单独相加


SELECT user_id,SUM(timepoint) as `point`
from
(
        SELECT user_id,floor(TIMESTAMPDIFF(minute,visit_time,leave_time)/10) as timepoint 
        from visit_tb
) t 
group by user_id
ORDER BY  `point` desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务