0
BallByBallID Deliveries RunsScored BowlPlayerId BatPlayerId
109 0 1 127 4
110 0.1 2 127 6
111 0.2 3 127 6
112 0.3 4 127 4
113 0.4 6 127 4
114 0.5 6 127 4
230 0 1 162 4
231 0.1 2 162 6
232 0.2 3 162 6
233 0.3 4 162 4
234 0.4 5 162 4
235 0.5 6 162 6
236 1 1 169 4
237 1.1 2 169 6
238 1.2 3 169 6
239 1.3 4 169 4
240 1.4 5 169 4
241 1.5 6 169 6
我有上述格式的數據。現在我想找到總和 RunsScored和BowlPlayerId爲最後插入的數據(該數據是動態的,過去六年可以隨時更改)基於上BallByBallId。 我試圖用這樣的辦法來解決問題.........如何根據另一列找到一列的最後六行(動態)總和
SELECT SUM(RunsScored) from (select BallByBallId from BallByBall ORDER BY BallByBallId DESC LIMIT 6);
這是給總有些......
SELECT SUM(RunsScored) from (SELECT top 6 * from BallByBall ORDER BY BallByBallId DESC) A GROUP BY A.BowlPlayerID
它顯示錯誤如..........................您的SQL語法錯誤;檢查對應於您的MySQL服務器版本的手冊,以便在第1行使用靠近'6 SUM(RunsScored)FROM BallByBall group by BallByBallId'的正確語法。 – 2015-02-11 07:06:11
試試這個..在工作 – 2015-02-11 08:31:45
同樣的查詢我已經嘗試過你提到的..........它顯示相同的錯誤.......我正在執行** mysql查詢瀏覽器** ... – 2015-02-12 04:55:16