当前我的代码是:
Find_in_set(beerkezes, (SELECT Group_concat(beerkezes ORDER BY beerkezes
ASC)
FROM versenyzo as x
WHERE beerkezes <> '00:00:00'
AND v.tav = x.tav AND `szuletesidatum`<`zarodate` AND `szuletesidatum`>`kezdodate` AND v.nem=x.nem))
我需要基于“ beerkezes”列获取子查询中该行的排名。最好使用索引等。 是的
答案 0 :(得分:0)
如果您使用的是MySQL 8.0,则可以使用ROW_NUMBER()
:
SELECT *, ROW_NUMBER() OVER(PARTITION BY x.nem, x.tav ORDER BY beerkezes) AS rn
FROM versenyzo as x
WHERE beerkezes <> '00:00:00'
AND `szuletesidatum`<`zarodate`
AND `szuletesidatum`>`kezdodate`