select a.m1, b.m2, b.m2-a.m1 from
(select t_type, sum(t_money) as m1 from family.statement where t_type=1 group by t_type) a
join
(select t_type, sum(t_money) as m2 from family.statement where t_type=2 group by t_type) b;
(select t_type, sum(t_money) as m1 from family.statement where t_type=1 group by t_type) a
join
(select t_type, sum(t_money) as m2 from family.statement where t_type=2 group by t_type) b;