求一SQL语句 求指导
我有两张表
A表
countsbg_type
31
13
24
B表
countsbg_type
11
12
13
求如下结果
countsbg_type
41
12
23
2 4
[解决办法]
select counts=sum(counts),bg_type
from (select * from A union all select * from B) t
group by bg_type
[解决办法]
- SQL code
select counts=sum(counts),bg_typefrom (select * from a union all select * from b) Kgroup by bg_type
[解决办法]
晕,猜了半天,用2楼的吧