DECLARE @T TABLE (ID1 INT)
DECLARE @TT TABLE (ID2 INT)
INSERT INTO @T SELECT 12
UNION ALL SELECT 22
INSERT INTO @TT SELECT 23
UNION ALL SELECT 33
--最后结果
SELECT (A.ID1+B.ID2) AS SUMS FROM
(SELECT SUM(ID1) AS ID1 FROM @T) A,
(SELECT SUM(ID2) AS ID2 FROM @TT)B