跳至主要內容

生产订单完工清单

五六零网校小于 1 分钟

代码示例

SELECT CASE 
		WHEN T0.[U_560_SCTYPE] = '1' THEN '自制'
		WHEN T0.[U_560_SCTYPE] = '3' THEN '委外'
	END AS '订单类型', T0.[DocNum], T0.[ItemCode], T0.[PlannedQty] AS '计划数量', T0.[CmpltQty] AS '完工数量'
	, T0.[U_560_sjsl], T0.[U_560_kjssl]
	, CASE 
		WHEN T0.[U_560_SCTYPE] = '1' THEN (
			SELECT TOP 1 T12.[Createdate]
			FROM [dbo].[@U_SJDM] T12
				INNER JOIN [dbo].[@U_SJDETAIL1] T13 ON t12.docentry = t13.docentry
			WHERE T12.[U_560_sjdtag] <> '3'
			ORDER BY T12.[DocEntry] DESC
		)
		WHEN T0.[U_560_SCTYPE] = '3' THEN (
			SELECT TOP 1 T14.[Createdate]
			FROM [dbo].[@U_SJDMWJG] T14
				INNER JOIN [dbo].[@U_SJDDWJG] T15 ON t14.docentry = t15.docentry
			WHERE T14.[U_560_sjdtag] <> '3'
			ORDER BY T14.[DocEntry] DESC
		)
	END AS '最后送检日期', T0.[DueDate] AS '生产到期日期'
FROM OWOR T0
WHERE T0.[DueDate] >= [%0]
	AND T0.[DueDate] <= [%1]
	AND T0.[U_560_SCTYPE] NOT IN ('2', '4')
ORDER BY T0.[DocNum] DESC