我需要这个Rank查询也要有一个IF语句来计算获胜/亏损并将百分比放入@percentage
变量中。我不知道如何将排名查询与百分比查询结合起来。
mysql_query("SELECT name, wins, losses, level, xp, @curRank := @curRank + 1 AS rank
FROM teams p, (SELECT @curRank := 0) r
WHERE `console` = 3 AND `game` = 23 AND `laddertype` = 1
ORDER BY xp DESC");
最佳答案
选择名称,获胜,损失,等级,xp,获胜W,损失AS L,TRUNCATE(胜/ IF(胜= 0,1,胜+损失)* 100,0)AS PCT,@curRank:= @curRank +来自团队p的1个AS等级,(选择@curRank:= 0)r WHERE console
= 3 AND game
= 23 AND laddertype
= 1 ORDER BY xp DESC;
关于php - 如何基于赢/亏损列在PHP中的Mysql查询中获取百分比,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27030303/