Select c.x1,c.x2,c.x3,sum(*) from ( select * from a where... union select * from b where...) c group by c.x1,c.x2,c.x3
Select x1,x2,x3,sum(你要的字段) from ( select * from a where... union select * from b where... ) c group by c.x1,c.x2,c.x3
create table a(x1 int ,x2 int,x3 int) create table b(x1 int ,x2 int,x3 int)Select AT.x1,T.x2,T.x3,sum(x1) from (select * from a union select * from b ) T group by T.x1,T.x2,T.x3
Select a.x1,a.x2,a.x3,sum(*) from ( select * from a where... union select * from b where... ) group by a.x1,a.x2,a.x3 WITH ROLLUP
Select a.x1,a.x2,a.x3,sum(*) from ( select * from a where... union select * from b where... ) a group by a.x1,a.x2,a.x3
create table a(x1 int ,x2 int,x3 int) create table b(x1 int ,x2 int,x3 int)select x1,x2,sum(x3) as sum_x3 from ( select x1,x2,x3 from a union select x1,x2,x3 from b )t group by x1,x2
from
( select * from a where... union select * from b where...) c
group by c.x1,c.x2,c.x3
from
(
select * from a where...
union
select * from b where...
) c
group by c.x1,c.x2,c.x3
create table b(x1 int ,x2 int,x3 int)Select AT.x1,T.x2,T.x3,sum(x1)
from
(select * from a
union select * from b
) T
group by T.x1,T.x2,T.x3
Select a.x1,a.x2,a.x3,sum(*)
from
(
select * from a where...
union
select * from b where...
)
group by a.x1,a.x2,a.x3 WITH ROLLUP
from
(
select * from a where...
union
select * from b where...
) a
group by a.x1,a.x2,a.x3
create table b(x1 int ,x2 int,x3 int)select x1,x2,sum(x3) as sum_x3 from
( select x1,x2,x3 from a
union
select x1,x2,x3 from b
)t
group by x1,x2