numeric類型字段相加減結果為NULL值,
請教如何解決
萬分感謝
SELECT STORE.MB001,STORE.LB003+LA003 AS 'QUANTITY'FROM
(
SELECT C.MB001,A.LB003 ,B.LA003
FROM
--料號
(SELECT MB001 FROM INVMB WHERE MB005='111') C
LEFT JOIN
-- 期初庫存
(select LB001,LB002,LB003
from INVLB a,INVMB c
where not exists (
select 1 from INVLB b
where b.LB001 = a.LB001
and b.LB002 > a.LB002
) AND a.LB001=c.MB001 AND c.MB005='111') A
ON C.MB001=A.LB001
LEFT JOIN
--後發生的交易數量
(
SELECT LA001,SUM(LA005*LA011) AS LA003
FROM INVLA,INVMB
WHERE LEFT(LA004,6)>=(select TOP 1 MAX(LB002) FROM INVLB)
AND INVLA.LA001=INVMB.MB001 AND INVMB.MB005='111'
GROUP BY LA001
) B
ON C.MB001=B.LA001
) STORE
------解决方案--------------------
用 isnull(column,0)
------解决方案--------------------
没问题啊,是不是你的数据问题?
DECLARE @a NUMERIC
SET @a=123
DECLARE @b NUMERIC
SET @b=234
SELECT SUM(a)
FROM (
SELECT @a A
UNION
SELECT @b A)a
/*
---------------------------------------
357
*/