SELECT SUM(CASE WHEN InOut_Code = '01' THEN CAST((CONVERT(MONEY, Price_unit) * InOut_Count) AS DECIMAL(38)) END) as a ,
SUM(CASE WHEN InOut_Code = '02' THEN CAST((CONVERT(MONEY, Consumer_Price) * InOut_Count) AS DECIMAL(38)) END) as b,
SS = (((SELECT SUM(CASE WHEN InOut_Code = '01' THEN CAST((CONVERT(MONEY, Price_unit) * InOut_Count) AS DECIMAL(38)) END) FROM Goods_Info G, Stock_Info S WHERE G.Goods_Code = S.Goods_Code AND InOut_Day >= '2009-02-24 05:35' AND InOut_Day <= '2009-02-27 05:35' )) -
(SELECT SUM(CASE WHEN InOut_Code = '02' THEN CAST((CONVERT(MONEY, Consumer_Price) * InOut_Count) AS DECIMAL(38)) END) FROM Goods_Info G, Stock_Info S
WHERE G.Goods_Code = S.Goods_Code AND InOut_Day >= '2009-02-24 05:35' AND InOut_Day <= '2009-02-27 05:35' ))
FROM Goods_Info G, Stock_Info S
WHERE G.Goods_Code = S.Goods_Code
AND InOut_Day >= '2009-02-24 05:35'
AND InOut_Day <= '2009-02-27 05:35'