跳至主要內容

销售订单明细查询

五六零网校小于 1 分钟

示例代码

SELECT T0.DocNum, T1.LineNum + 1 AS '行号', T0.DocDate, T0.CardCode
	, T0.CardName, t5.SlpName
	, CASE 
		WHEN T0.DocStatus = 'C'
		AND T0.CANCELED = 'N'
		AND T0.DocManClsd = 'N' THEN '已发货'
		WHEN T0.DocStatus = 'O' THEN '未请'
		WHEN T0.DocStatus = 'C'
		AND T0.CANCELED = 'Y' THEN '已取消'
		WHEN DocManClsd = 'Y'
		AND DocStatus = 'C' THEN '手工关闭'
	END AS '单据状态', T1.ItemCode, T1.Dscription, Quantity, T1.OpenQty
	, T1.unitMsr, T1.PriceAfVAT AS '含税单价', T1.GTotal, T1.NumPerMsr * T1.Quantity AS '库存单位数量'
	, t2.InvntryUom, t3.WhsName
FROM ORDR T0
	INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
	LEFT JOIN OITM t2 ON T1.ItemCode = t2.ItemCode
	LEFT JOIN OWHS t3 ON t3.WhsCode = T1.WhsCode
	LEFT JOIN OCRD t4 ON t4.CardCode = T0.CardCode
	LEFT JOIN OSLP t5 ON t4.SlpCode = t5.SlpCode
WHERE (T0.DocDate >= [%1]
		OR [%1] = '')
	AND (T0.DocDate <= [%2]
		OR [%2] = '')