I need to add the 3 tables the divide by table 4 totals. Not sure the best method, something like? SELECT (Sum(artotal.ub)+Sum(bdtotal.ub)+Sum(WRITEOFFTOTAL.ub))/Sum(maintotal.ub) AS ubcalcFROM ARTOTAL INNER JOIN (BDTOTAL INNER JOIN (WRITEOFFTOTAL INNER JOIN MainTotal ON WRITEOFFTOTAL.FinClass = MainTotal.FinClass) ON BDTOTAL.FinClass = WRITEOFFTOTAL.FinClass) ON ARTOTAL.FinClass = BDTOTAL.FinClass group by maintotal.finclass,maintotal.ub;
I need to display the % by finclass
Solution: SQL SUM STATEMENT HELP
Here's another way of presenting the SQL. You should develop some consistency in the presentation of your names using upper and lower case.
SELECT ( Sum(ARTotal.ub) + Sum(BDTotal.ub) + Sum(WriteOffTotal.ub)) / Sum(MainTotal.ub) AS UBCalc FROM ARTotal INNER JOIN (BDTotal INNER JOIN (WriteOffTotal INNER JOIN MainTotal ON WriteOffTotal.FinClass = MainTotal.FinClass) ON BDTotal.FinClass = WriteOffTotal.FinClass) ON ARTotal.FinClass = BDTotal.FinClass GROUP BY MainTotal.FinClass, MainTotal.ub;
Why is MainTotal.ub in the GROUP BY. Note you need a space between UBCalc and FROM.