I recently created a question, although it wasn't worded well and had no examples, a member suggested I should recreate the question, as the past had no answer.
I'm trying to get a row's position from an ordered query, in the most efficient way possible. I'm planning on having to search over 10,000 results, so I need to be as efficient as possible.
I currently have
SELECT p.*,
(SELECT count(DISTINCT prank)+1
FROM uprofile WHERE prank > p.prank
) AS POSITION
FROM uprofile p
WHERE uid = " . $profile->data()->uid . "
ORDER BY prank DESC
Which should output POSITION as 2; uid
is the value 31, and uprofile's row that has a uid value of '31' has the second most player prank (prank).
This all works good, except from two rows having the same reputation. My current data, only 3 rows are populated with player rank. The rest of the dummy rows have prank set to 0, which causes their position to all be 4.
How would I modify the SQL to return unique values, rather than some rows having the same position?