求两张表相同字段的和?
表1 有"重量"字段 表2 也有"重量"字段 ,求条语句为两张表,表1.SUM(重量) + 表2.SUM(重量)
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