例如,我有以下数据:
rank value
___________________
1 "A"
2 "B"
5 "C"
3 "D"
4 "E"
6 "F"
我只想在等级增加时选择值,所以我应该只获得
"A", "B", "C", "F".
谢谢!
答案 0 :(得分:0)
假设有数字id列,则可以使用此查询:
SELECT
value
FROM
tbl AS t1
WHERE
(SELECT IFNULL(MAX(rank), 0) FROM tbl AS t2 WHERE t2.id < t1.id) < t1.rank
因为第一行,IFNULL就在那里。