The database has the table persons
:
id int
points int
voted_on int
other columns
I want to know which row rank the row with id
x has, rows with same points has same row rank. This query works great and fast: (but tell me if you know even better one:)
select count(*)
from persons p cross join
(select points from persons p where p.id = x) const
where p.points > const.points;
But now I would like to upgrade the query that people with less voted_on, but same amount of points, have a better row rank than people with more voted_on. However, people with same amount of points and voted_on should have the same row rank.