mysql如何表示排名4~6名

mysql如何表示排名4~6名,第1张

按照并列且占位。

mysql按照并列且占位的规则来排名,例如96分应该是第四名,95分是第6名。

mysql排名并列即相同的值,相同的值保留重复名次,遇到下一个不同的值,跳跃到总共的排名。

select id,integral,addtime from cos_member_vip order by integral desc,addtime asc

--如果需要生成以积分为最高优先,其次以时间为从高到低为条件生成个排名字段,可用

--ROW_NUMBER() OVER ()函数

select t.songid,sum(score) sumscore from

(select songid,count(*)*1 score from collection group by songid

union all

select songid,count(*)*1 score from identification group by songid

union all

select songid,count(*)*0.5 score from listen group by songid) t

order by sum(score) desc limit 5

这样试试呢?


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6110528.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存