SELECT field1, field2, SUM(field3) FROM table1, table2, table3 WHERE table1.id1 = table2.id1 AND table2.id2=table3.id2 GROUP BY field1, field2