tidb版本:TiDB-v3.0.13
mysql版本:5.7.25
sql:
select * from (
select id,
@curRank := IF(@prevRank = a.id, @curRank, @incRank) as rankIdx,
@incRank := @incRank + 1,
@prevRank := a.id
from (select 1 as id union select 2 as id) a,
(SELECT @curRank := 0, @incRank :=1, @prevRank := NULL) r
order by a.id desc ) s
limit 1,1;
mysql下返回:
tidb下返回:
请问为什么tidb下返回的rankIdx是1而不是2啊