还有一种写法,作用相当于是窗口函数 DENSE_RANK() SELECT emp_no,salary, CASE WHEN @prevRank = salary THEN @curRank WHEN @prevRank := salary THEN @curRank := @curRank + 1 END AS t_rank FROM salaries, (SELECT @curRank :=0, @prevRank := NULL) r ORDER BY salary desc,emp_no