php - Getting a rank from a SQL total column -
i have mysql table so...
id | name | rank | pts ---+-------+------+---- 12 | john | 1 | 28 18 | andy | 2 | 31 23 | brian | 3 | 16 41 | mike | 4 | 33 15 | jack | 5 | 35 68 | anne | 6 | 24
i sort by...
select * `ranks` order pts desc
i looking code can give id
, , it'll return it's ranking pts column. id 41, should return 2 2nd best score of column.
i not sure google answer. there sql code can simply? or maybe php? rank
column overall rank, , pts
current weekly score far. there might 2.5 million entries eventually. please let me know if have questions.
// number of ppl w/ points higher given user's select count(*) + 1 ranks pts > ( select pts ranks id = 41);
...though if looking scale want reconsider how structuring data.
Comments
Post a Comment