当有三张表ABC,都有共同字段d,想查出d在三张表存在的几种情况进行统计用分组来实现,
select sum(ziduan1),sum(ziduan2),sum(ziduan3),d
from ((select ziduan1,ziduan2,ziduan3,d from A where ....) union
(select ziduan1,ziduan2,ziduan3,d from B where ....) union
(select ziduan1,ziduan2,ziduan3,d from c where ....)) p where p.d is not null
group by p.d
可以添加多个分组字段