以下语句是得出一个排名的字段,但是只有CNT值相同则下一个名次就不对了,如截图,请问如何解决?
select *,(select count(1)+1 from loginCnt a where a.cnt>b.cnt) as 名次
from loginCnt b order by cnt desc
select *,(select count(1)+1 from loginCnt a where a.cnt>b.cnt) as 名次
from loginCnt b order by cnt desc
fish 38 1
9999 21 2
cars 20 3
hyjia 19 4
58148 16 5
50335 16 5
yong1 7 7
2246 6 8
58148 6 8
82675 6 8
9999 4 11
from loginCnt
select *,(select count(DISTINCT a.cnt)+1 from loginCnt a where a.cnt>b.cnt) as 名次
from loginCnt b order by cnt desc
(select count(1)+1 from loginCnt a where a.cnt>b.cnt) as 名次
from loginCnt b order by 名次 desc