+----+---------+-------+
| id | user_id | value |
+----+---------+-------+
| 1 | 1 | 500 |
| 2 | 1 | -200 |
| 3 | 1 | -100 |
| 4 | 1 | 50 |
+----+---------+-------+
SELECT user_id, SUM(value) as value FROM balance GROUP BY user_id;