简化后的:
SELECT *, a.amount_1 - b.amount_2 AS amount_3, '未付' AS label_3
FROM (
SELECT SUM(amount) AS amount_1, '总数' AS label_1 FROM table_1
) AS a
FULL OUTER JOIN (
SELECT SUM(amount) AS amount_2, '已付' AS label_2 FROM table_2
) AS b ON 1=1
select amount_1 amount,label_1 label from 表
union all
select amount_2 amount,label_2 label from 表
union all
select amount_3 amount,label_3 label from 表
select sum(case when label='总数' then amount end) aaa,
sum(case when label='已付' then amount end) bbb,
sum(case when label='未付' then amount end) bbb,
from table6
select amount_1 amount,label_1 label from 表
union all
select amount_2 amount,label_2 label from 表
union all
select amount_3 amount,label_3 label from 表