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

Trova la classifica di un intero in mysql

Ordinato per country ASC :

SELECT 1+COUNT(*) AS ranking
FROM countryTable
WHERE country < 45 ;

Ordinato da clicks DESC :

SELECT 1+COUNT(*) AS ranking
FROM countryTable AS t
  JOIN countryTable AS c
      ON c.clicks > t.clicks
WHERE t.country = 45 ;