我对这个案例陈述和公式有一个非常奇怪的问题,即使我独立运行每个语句,我得到正确的数字。如果我删除第二个selet语句甚至输入数字,我仍然得到零。数字出现在167913/1150972,如果我将第二个数字截断为1150它可以工作,但如果我加入9我得到0返回。
CASE WHEN
ISNULL(MAX(JC.JOB_SHIPPED_FLAG), MAX(OE10.ORD_SHIPPED_FLAG)) = 'P' AND ISNULL(MAX(JC.JOB_STATUS_FLAG), MAX(OE10.ORD_STATUS_FLAG)) = 2
THEN (SELECT SUM(CAST(TOT_COST AS INT)) FROM CRCDATA.DBO.LA15
WHERE EST_NUMB = MAX(JC.EST_NUMB) AND LA15.QTY_SLOT =1)
/
((SELECT DISTINCT SUM(CAST(FG14.ONHAND_QTY AS INT)) FROM CRCDATA.DBO.JC11 JC11
LEFT OUTER JOIN CRCDATA.DBO.FG14 FG14 ON JC11.FG_ITEM_NUMB = FG14.ITEM_NUMB
WHERE JC11.FG_ITEM_NUMB LIKE '0000000%' AND JC11.STATUS_FLAG = 'P' AND FG14.LOC <> 'rej' ) +
(SELECT SUM(CAST(SHIPTO_FAX AS INT)) FROM CRCDATA.DBO.SH10 WHERE RECORD_TYPE = 'B' AND PROCESS_FLAG = 4 AND SH10.JOB_NUMB = A.JobNumber))
ELSE 0
END [TEST]
答案 0 :(得分:1)
您必须将任何一个分频器或红利投射到FLOAT。即。
expect
或强>
SELECT CAST(val1 AS FLOAT) / val2
答案 1 :(得分:0)
只需在您的某个值
中添加“+.0”即可例如
Select 5/20 Return 0
Select 5/(20+.0) Return 0.2500000