【UNION ALL】
select a,b,sum(sm) AS s1, SUM(qm) AS s2 from
(
select 'a' AS a, 'b' AS b, 2 AS sm, 200 AS qm
UNION ALL
select 'a' AS a, 'b' AS b, 2 AS sm, 200 AS qm
)r
group by a,b
ab4400
【UNION】
select a,b,sum(sm) AS s1, SUM(qm) AS s2 from
(
select 'a' AS a, 'b' AS b, 2 AS sm, 200 AS qm
UNION
select 'a' AS a, 'b' AS b, 2 AS sm, 200 AS qm
)r
group by a,b
ab2200
总结:UNION ALL全部列出,UNION会去掉重复的。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。