销售订单按客户查询
小于 1 分钟
示例代码
SELECT t0.DocNum, t1.LineNum + 1 AS '行号', t0.DocDate, t0.CardCode
, t0.CardName
, 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, t1.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
WHERE (t0.DocDate >= [%1]
OR [%1] = '')
AND (t0.DocDate <= [%2]
OR [%2] = '')
AND T0.cardcode LIKE '%[%3]%'