SELECT user_id, SUM(FLOOR(TIMESTAMPDIFF(SECOND,visit_time,leave_time) / 60 / 10)) AS 'point' FROM visit_tb AS a GROUP BY user_id ORDER BY point DESC;