-- 实现同分同名 ,名次按顺序不跳
SELECT
obj.Entered_ID,
obj.msisdn,
CASE
WHEN @rowtotal = obj.VoteNumber THEN
@rownum
WHEN @rowtotal := obj.VoteNumber THEN
@rownum :=@rownum + 1
WHEN @rowtotal = 0 THEN
@rownum :=@rownum + 1
END AS rank ,
obj.VoteNumber,
NOW() AS create_time FROM
(
SELECT
Entered_ID,
msisdn,
VoteNumber
FROM
Entered
ORDER BY
VoteNumber DESC
LIMIT 0,200
) AS obj,
(SELECT @rownum := 0 ,@rowtotal := NULL) r;