SUM from multiple tables
Posted: Wed Sep 06, 2006 12:54 pm
I want to select a sum of values...but from multiple tables.
The problem I am having is that there is a different number of rows in each table and the JOIN is adding rows to the other table
I also need to add a customer table to this statement and GROUP BY the customer number or customer state
Code: Select all
$sql = "
SELECT SUM(a.sales_type1), SUM(b.sales_type2)
FROM type1 AS a, type2 AS b
WHERE a.id = b.id";I also need to add a customer table to this statement and GROUP BY the customer number or customer state