日期:2014-05-16 浏览次数:20530 次
SELECT a.WS_ProName, a.WS_ProductColor, a.WS_ProductIntr, ISNULL(a.WS_CheckNum, 0) AS Expr1, ISNULL(b.WS_CheckNum, 0) AS Expr2,
ISNULL(a.WS_CheckNum, 0) - ISNULL(b.WS_CheckNum, 0) AS StoreNum
FROM (SELECT WS_MaterialFlag, WS_ProName, WS_ProductColor, WS_ProductIntr, SUM(WS_CheckNum) AS WS_CheckNum
FROM HR_GetMaterialDetail
GROUP BY WS_ProName, WS_ProductColor, WS_ProductIntr, WS_MaterialFlag) AS a LEFT OUTER JOIN
(SELECT WS_ProName, WS_ProductColor, WS_ProductIntr, SUM(WS_CheckNum) AS WS_CheckNum
FROM HR_TakeMaterialDetail
GROUP BY WS_ProName, WS_ProductColor, WS_ProductIntr) AS b ON a.WS_ProName = b.WS_ProName AND
a.WS_ProductColor = b.WS_ProductColor AND a.WS_ProductIntr = b.WS_ProductIntr
WHERE (a.WS_MaterialFlag = 1) AND (a.WS_ProName LIKE '%联想%')
declare @a decimal(12,3)
set @a=10
select @a as a
----------------------------
--结果
a
---------------------------------------
10.000
(1 行受影响)