SET @rank=0;
SELECT @rank:=@rank+1 AS rank, p.user_id, SUM(ch.integer) as sum
FROM profile p
LEFT JOIN chronometry ch ON ch.user_id = p.user_id
GROUP BY p.user_id
ORDER BY sum DESC;
SET @rank=0;
SELECT @rank:=@rank+1 AS rank, s.*
FROM (
SELECT p.user_id, SUM(ch.integer) as sum
FROM profile p
LEFT JOIN chronometry ch ON ch.user_id = p.user_id
GROUP BY p.user_id
ORDER BY sum DESC
) s