Get count of value row
This is an example of getting the rankings:




select version();



| version() |
| :-------- |
| 8.0.13    |






CREATE TABLE person( name CHAR(10), money INT );



✓






INSERT INTO person VALUES
  ('Smith',10),('Jones',15),('White',20),
  ('Black',40),('Green',50),('Brown',20);



✓






SELECT name, money, rank() OVER(win) AS 'Richest'
FROM person
WINDOW win AS (ORDER BY money DESC); 



name  | money | Richest
:---- | ----: | ------:
Green |    50 |       1
Black |    40 |       2
White |    20 |       3
Brown |    20 |       3
Jones |    15 |       5
Smith |    10 |       6



db&lt;>fiddle here

Note this code is for MySQL-8.0 or MariaDB-10.2+. For earlier version implementations see this example

To get a value for a single user:

SELECT COUNT(*) + 1 AS "Richest"
FROM person p
JOIN person richer
  ON p.money &lt; richer.money
WHERE p.name="Brown"


This doesn't have any version requirements.

Ref this fiddle.