结果1数据 No data 结果2数据 No data
1 15 1 5
2 20 2 5
3 25 3 5
----------------------------------------
最后想要合并的结果是No data
1 20
2 25
3 30
就是No不变,将两个结果的data相加,得出一个新的结果
1 15 1 5
2 20 2 5
3 25 3 5
----------------------------------------
最后想要合并的结果是No data
1 20
2 25
3 30
就是No不变,将两个结果的data相加,得出一个新的结果
from (
select * from A
union all
select * from B
) t
group by no
select no,data from 表a
union all
select no,data from 表 b)t
group by no
from 结果1 a,结果2 b
where a.no=b.no
select no,data from 表a
union all
select no,data from 表 b
)t group by no
order by no
(
SELECT COL1,COL2 FROM TA
UNION ALL
SELECT COL1,COL2 FROM TB
)
T
GROUP BY COL2
select No ,sum(data)
from(
select No ,data
from 表1
union all
select No ,data
from 表2)a
group by No