I have 4 tables that T2 is related to Tb1 and other Tb3 and T4 is related to the Tb2. as showing in the picture bellow . what i am trying to do is to get the totals from Tb3 And Tb4 biased on the Tb1 id which is related Tb2 Sql-Query Image
SELECT DepartmentType.Type_ID, DepartmentType.DepType, SUM(TransByDep.Amount) AS SALES, SUM(TRANSUP.Check_amount) AS PURCHASE
FROM dep INNER JOIN
DepartmentType ON dep.Type_ID = DepartmentType.Type_ID INNER JOIN
TransByDep ON dep.Dep_ID = TransByDep.Dep_Id INNER JOIN
TRANSUP ON dep.Dep_ID = TRANSUP.Dep_id
GROUP BY DepartmentType.Type_ID, DepartmentType.DepType
this what i have triad but it give me wrong numbers