MySQL查询帮助按ID查找排名
|
我正在尝试修改以下查询以查找特定videoid的等级,但是我运气不好,有人可以建议解决方案吗?
SELECT videoid wins/loses as win_loss,
@curRank := @curRank + 1 AS rank
FROM cb_video,
(SELECT @curRank := 0) r
ORDER BY wins/loses DESC
我试图做这样的子查询,但失败了:
SELECT rank
FROM (SELECT videoid wins/loses as win_loss,
@curRank := @curRank + 1 AS rank
FROM cb_video,
(SELECT @curRank := 0) r
ORDER BY wins/loses DESC)
WHERE videoid = 116
同样在没有子查询的情况下将videoid添加到WHERE子句中,总是将排名显示为#1位置,因为它仅返回一行:
SELECT videoid wins/loses as win_loss,
@curRank := @curRank + 1 AS rank
FROM cb_video,
(SELECT @curRank := 0) r
WHERE videoid = 116
ORDER BY wins/loses DESC
有什么想法如何将结果限制为特定的ID,但仍保留排名?仅供参考,如果有帮助,我会保留两列(输赢)。
没有找到相关结果
已邀请:
3 个回复
览幕堤分
门锑腺潮
诫商