我意外地運行了一次查詢兩次,並且我的數據庫中的所有點都弄亂了(3000條記錄)。每個結果搞砸了SQL數據 - 在更新語句中選擇
4強已經固定去年和5之間的結果,但點計算(去年是100pts)。
Click here更多信息
我基本上是需要這個語句轉換爲SQL:
分= 100 +((100 /(NumberOfResults - 4))*(NumberOfResults - PositionOfResult))
如何獲得select語句以分別引用Select和Update表。這不起作用:
UPDATE Results R1
SET R1.Points = 100 + ((100/((SELECT TOP 1 R2.Position FROM Results R2 WHERE R2.Date = R1.Date AND R2.ContestID = R1.ContestID ORDER BY R2.Position DESC)-4) * ((SELECT TOP 1 R2.Position FROM Results R2 WHERE R2.Date = R1.Date AND R2.ContestID = R1.ContestID ORDER BY R2.Position DESC)-R1.Position)))
WHERE R1.ContestID > 11
AND R1.Position > 4
AND R1.Position < (SELECT TOP 1 R2.Position FROM Results R2 WHERE R2.Date = R1.Date AND R2.ContestID = R1.ContestID ORDER BY R2.Position DESC)
遺憾的髒話,這是複製並粘貼@amimunson – 2014-12-05 20:20:58