I have a union of three tables (t1,t2,t3). Each rerun exactly the same number of records, first column is id, second amount:
1 10 2 20 3 20 1 30 2 3
Subquery:
SELECT id, SUM(amount) FROM ( SELECT * FROM t1 UNION ALL SELECT * FROM t2 UNION ALL SELECT * FROM t3 ) GROUP BY id