我需要此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");
答案 0 :(得分:0)
SELECT name,wins,loss,level,xp,wins AS W,loss AS L,TRUNCATE(wins / IF(wins = 0,1,wins + loss)* 100,0)AS PCT,@curRank:= @curRank + 1 AS排名来自团队p,(SELECT @curRank:= 0)r WHERE console
= 3 AND game
= 23 AND laddertype
= 1 ORDER BY xp DESC;