id | userid | total_points_spent
1 | 1 | 10
2 | 2 | 15
3 | 2 | 50
4 | 3 | 5
5 | 1 | 15
userid
上記の表を使用して、最初に、次のように、最大の行を保持する重複を削除したいと思いますtotal_points_spent
。
id | userid | total_points_spent
3 | 2 | 50
4 | 3 | 5
5 | 1 | 15
次に、の値を合計したいと思いますtotal_points_spent
。これは簡単な部分であり、結果として70
。