我在存储过程中有一个union all查询.
我想做的是Sum a column并将该查询返回给客户端
我该怎么做?
马尔科姆
SELECT othercol1, othercol2, SUM(bar) FROM ( SELECT othercol1, othercol2, bar FROM RT UNION ALL SELECT othercol1, othercol2, bar FROM FM ) foo GROUP BY othercol1, othercol2
SELECT SUM(MyCol) FROM ( SELECT ... MyCol FROM Table1 UNION ALL SELECT ... MyCol FROM Table2 )as tbl