This is an extension of the last question I had. In this case I'm trying to join in the sum of grouping where I also added together values in each row. I thought something like this would work:select a.id, b.id, c.id, d.cnt, e.smfrom tableA a left join tableB b on a.id = b.aid left join tableC c on b.id = c.bid left join (select aid,count(*) as cnt from tableD group by aid) d on d.aid = a.aid left join (select aid, (sum(colA) + sum(colB)) as sm from tableE group by aid) e on e.aid = a.aid
That last join statement is apparently wrong. What should it be?