mysql 分数排名

需求,投票系统,不order by票数的情况下计算各位参赛选手的排行榜

SELECT id,name,num,
(SELECT count(DISTINCT 字段) FROM 表名 AS b WHERE a.字段<b.字段)+1 AS rank
FROM 表名 AS a

Pasa吴

TP5模型
$field = "*,(SELECT count(DISTINCT num) FROM charitable_player AS b WHERE a.num<b.num)+1 AS rank";
$lists = $this->model->alias('a')->field($field)-select();
        

https://www.cnblogs.com/aeiou/p/5719396.html

Pasa吴技术博客
请先登录后发表评论
  • latest comments
  • 总共0条评论