Q: Combining Two Select Sum Statements Into One I have two statements within my table which work fine individually like this:
SELECT fee_earner, (SUM(fe_fees)) AS Total
FROM fees
GROUP BY fee_earner
order by Total desc;

SELECT supervisor, (SUM(sv_fees)) AS Total
FROM fees
GROUP BY supervisor
order by Total desc;

But there are some cases where the fee_earner and supervisor fields have the same person as the data, is there a way to combine these two statements into one to get the overall totals?

A: You can use union all for this:
SELECT person, sum(fe_fees) as fe_fees, sum(sv_fees) as sv_fees,
       (sum(fe_fees) + sum(sv_fees)) as total
FROM ((select fee_earner as person, fe_fees as fe_fees, 0 as sv_fees, 'earner' as which
       from fees
      ) union all
      (select supervisor as person, 0 as fe_fees, sv_fees as sv_fees, 'supervisor' as which
       from fees
      )
     ) t
GROUP BY person
order by Total desc;


A: select
    fee_earner, SUM(fe_fees) as total, SUM(sv_fees) as total2, 
    SUM(fe_fees) + SUM(sv_fees) as wholeTotal
from 
    fees 
group by 
    fee_earner, supervisor 
order by 
    Total desc;

