关联一个 ( SELECT @id := 0 ) idVal,用逗号就行,或者用join 且要嵌套多层
select t2.* from ( select ( @id := @id + 1 ) AS id, t.* from ( SELECT COUNT( act.visit_no ) rankCount, act.nameFROM activity_clock_type act
WHERE act.activity_no = #{activityNo} GROUP BY act.staff_no ORDER BY rankCount DESC , act.create_time asc ) t , ( SELECT @id := 0 ) idVal ) t2