我是SQL新手,我想寫一個查詢來在表中添加多行。添加特定的多行(SQL)
例如:
表:
matchid|player1id|player2id|player1score|player2score
101 |20 |10 |0 |100
101 |20 |10 |0 |100
101 |20 |10 |0 |100
201 |20 |10 |645 |0
201 |20 |10 |100 |700
201 |20 |10 |0 |100
需要的輸出:
matchid|player1id|player2id|player1score|player2score
101 |20 |10 |0 |300
201 |20 |10 |745 |800
注:我必須這樣做,而不使用GROUP BY
'SELECT \t matchid, \t player1id, \t player2id, \t player1score = SUM(player1score), \t player2score = SUM(player2score) FROM yourTable GROUP BY \t matchid,player1id,player2id' –
爲什麼你不想使用'GROUP BY'? –
,因爲它的運營成本很高 – Khubaib