跳至主要內容

采购订单交期查询

五六零网校小于 1 分钟

逻辑:以采购订单为核心,跟踪所有相关业务单据

代码示例

SELECT CASE 
		WHEN datediff(d, T0.[DocDueDate], GetDate()) > 0 THEN '交期超' + ' ' + CAST(datediff(d, T0.[DocDueDate], GetDate()) AS nvarchar) + '天'
		WHEN datediff(d, T0.[DocDueDate], GetDate()) < 0 THEN '交期剩' + ' ' + CAST(datediff(d, GetDate(), T0.[DocDueDate]) AS nvarchar) + '天'
	END AS '交期' ,T0.[DocNum], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription]
	, T1.[Quantity], T0.[TaxDate]
	
FROM OPOR T0
	INNER JOIN POR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
WHERE  T0.[DocDate]>=[%0] and  T0.[DocDate]<=[%1]
ORDER BY T0.[DocNum] DESC