【大厂真题】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
# 需求分析 单个记录/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
相关推荐