Mysql
 sql >> Database >  >> RDS >> Mysql

come ottenere il rango di posizione di una riga specifica usando solo la query mysql?

SELECT users1.id, (users1.points+users1.extra_points) AS total, COUNT(*)+1 AS rank
FROM users users1
INNER JOIN users users2 ON users1.points+users1.extra_points < users2.points+users2.extra_points
WHERE users1.id = $id