0
我收到錯誤'>'附近的語法不正確 每個字段都包含十進制值,其中NOT NULL和默認值爲零。 我試過不同的括號,我相信我只是在某處忘記了CASE語句的格式。SQL CASE在與邏輯
AND CASE WHEN QtyIssued <> 0 OR WM.QtyToMake <> 0 OR WMat.UnitQtyReqd <> 0 THEN QtyIssued/WM.QtyToMake * WMat.UnitQtyReqd >= .68 ELSE 0 END
我需要在每個值的檢查零,所以我不被零
得到將整個SQL列出如下:
SELECT SUBSTRING([SalesOrder], PATINDEX('%[^0]%', [SalesOrder]+'|'), LEN([SalesOrder])) AS SO, WM.SalesOrderLine AS SOLine,
SUBSTRING(WM.Job, PATINDEX('%[^0]%', WM.Job+'|'), LEN(WM.Job)) AS Job, WMat.StockCode, --WM.QtyToMake * WMat.UnitQtyReqd AS Qty2IssuedValue,
CEILING(WM.QtyToMake * WMat.UnitQtyReqd) AS Qty2Issue,
CEILING(WMat.QtyIssued) AS QtyIssued, WMP.WipRelease, WM.JobTenderDate,
WM.Complete ,
CASE WHEN QtyIssued = 0 OR WM.QtyToMake = 0 OR WMat.UnitQtyReqd = 0
THEN 0 ELSE (QtyIssued/(WM.QtyToMake * WMat.UnitQtyReqd)) END AS QtyNotAllocated
FROM dbo.WipMaster AS WM INNER JOIN
dbo.[WipMaster+] AS WMP ON WM.Job = WMP.Job FULL OUTER JOIN
dbo.WipJobAllMat AS WMat ON WM.Job = WMat.Job
WHERE (WMP.WipRelease BETWEEN CONVERT(DATETIME, '2016-04-01 00:00:00', 102) AND
CONVERT(DATETIME, '2016-04-29 00:00:00', 102))
AND CASE WHEN QtyIssued <> 0 OR WM.QtyToMake <> 0 OR WMat.UnitQtyReqd <> 0 THEN QtyIssued/WM.QtyToMake * WMat.UnitQtyReqd >= .68 ELSE 0 END
我要去的是吃我的蛋糕,也吃了它。 LOL –
我想查看列中具有零值的那些,但沒有除以零的問題。所以,這裏是我想出的...對不起,新的論壇和工作如何使用它... –
AND((QtyIssued <> 0或WM.QtyToMake <> 0或WMat.UnitQtyReqd <> 0 )AND \t \t \t \t \t \t \t \t \t QtyIssued/NULLIF(WM.QtyToMake,0)* WMat.UnitQtyReqd> = 0.68 OR \t \t \t \t \t \t \t \t \t QtyIssued = 0 OR WM.QtyToMake * WMat .UnitQtyReqd = 0 –