为什么我的查询在此之后中断?我基本上是基于两个表的列运行计算,然后在rn是1到5000之间的某个值时设置它们的pvplevel。
设置pvpranking.pvplevel=case
USE DNWorld
GO
WITH cte AS (
SELECT PVPScores.PVPWin, PVPScores.PVPLose, PVPRanking.Death, PVPRanking.[Kill], PVPRanking.PVPExp,
RANK() OVER (ORDER BY (((PVPScores.PVPWin * 1) + (PVPRanking.[Kill] * 0.2) + (PVPRanking.PvpExp * 0.002)) - ((PVPScores.PVPLose * 0.5) + (PVPRanking.Death * 0.1) + (PVPScores.PvPGiveUp * 0.5))) DESC, PVPScores.CharacterID DESC ) AS rn
FROM PvPRanking
INNER JOIN PVPScores
ON PVPRanking.CharacterID = PVPScores.CharacterID
)
UPDATE cte
SET PVPRanking.PVPLevel = CASE
WHEN rn = 1 THEN 26 -- #1 Rank Champion
WHEN rn BETWEEN 2 AND 10 THEN 25 -- Reita
WHEN rn BETWEEN 11 and 20 THEN 24 -- Warlord
WHEN rn BETWEEN 21 and 30 then 23 -- Slayer
WHEN rn BETWEEN 31 and 40 then 22 -- WATCH OUT
WHEN rn BETWEEN 41 and 50 then 21 -- Royalty
WHEN rn BETWEEN 51 and 60 then 20 -- Knight of Justice
WHEN rn BETWEEN 61 and 70 then 19 -- Furious Fiend
WHEN rn BETWEEN 71 and 85 then 18 -- Devil of PVP
WHEN rn BETWEEN 86 and 100 then 17 -- God Of PvP
WHEN rn BETWEEN 101 and 125 then 16 -- Death God
WHEN rn BETWEEN 126 and 150 then 15 -- Master
WHEN rn BETWEEN 151 and 175 then 14 -- Unpredictable Demon
WHEN rn BETWEEN 176 and 250 then 13 -- Demon
WHEN rn BETWEEN 251 and 300 then 12 -- Crazy Fiend
WHEN rn BETWEEN 301 and 400 then 11 -- Fiend
WHEN rn BETWEEN 401 and 500 then 10 -- Bloodthirsty
WHEN rn BETWEEN 501 and 600 then 9 -- Kavalan
WHEN rn BETWEEN 601 and 700 then 8 -- Keepo
WHEN rn BETWEEN 701 and 800 then 7 -- Senior PvP Tactician
WHEN rn BETWEEN 801 and 900 then 6 -- PvP Tactician
WHEN rn BETWEEN 901 and 1000 then 5 -- Senior Apprentice
WHEN rn BETWEEN 1001 and 1100 then 4 -- Apprentice
WHEN rn BETWEEN 1101 and 1500 then 3 -- Lesser Novice
WHEN rn BETWEEN 1501 and 2000 then 2 -- Novice
WHEN rn BETWEEN 2000 and 5000 then 1 -- Egg
ELSE 1
END
WHERE rn <= 5000;
1条答案
按热度按时间a7qyws3x1#
似乎您只需要包括
PVPLevel
在cte的选择列表中:然后,按原样继续当前的更新查询。请注意,更新本身可以简化一点,因为范围检查总是从上到下递增: