我提出了一个查询以获得工资,最后汇总了结果,但我想添加一个文本'Total'。
select which as 'Salaries', IFNULL(SUM(which1),0) as actual,IFNULL(SUM(which2),0) As estimated
from(select Type_expenses_table as which, sum(Amount_expenses_table) as which1, null as which2
From bacci.expenses_table
WHERE Date_expenses_table >= '2017-01-01'
AND Date_expenses_table < '2017-01-01' + INTERVAL 1 YEAR
AND Categories_table = 'salaries'
group by Type_expenses_table
union all
select estimated_type as which, null as which1, sum(estimated_amount) as which2
From bacci.estimated_expenses_table
Where estimated_year = '2017'
AND Categories = 'salaries'
group by estimated_type
) ae
group by which with rollup;
我想把Total而不是null