2
以下是將採購訂單鏈接到銷售訂單的查詢。我的理解是,爲了將交付文檔編號包括到此報告中,我需要再添加一個表格 - ODLN(因此將會有一個名爲「Delivery Doc#」又名[ODLN.DocNum]的字段)。我的問題是我不知道如何在下面的查詢中加入ODLN而不會搞亂任何東西。添加交付信息以在SAP Crystal Reports中查詢
ODLN.DocNum很大程度上驗證了PO在SO提交時的位置。
SELECT DISTINCT
o.CardName AS 'Customer Name'
,(isnull(c1.Street,'') + ', ' + isnull(c1.Block,'') + ', ' + isnull(c1.City,'') + ', ' + isnull(c1.[State],'') + ' ' + isnull(c1.ZipCode,'')) AS 'Customer Address'
,cpr.[Name] AS 'Customer Contact'
,cpr.Tel1 AS 'Customer Phone'
,cpr.E_MailL AS 'Customer Email'
,o.DocNum AS 'Sales Order #'
,p.DocNum AS 'PO # to Barracuda'
,l.ItemCode AS 'SKU'
,l.Dscription AS 'Desc'
,l.Quantity AS 'Qty'
,l.Price
,s.SlpName AS 'Sales Rep'
FROM
ORDR o
INNER JOIN RDR1 l ON o.DocEntry = l.DocEntry
LEFT JOIN POR1 p1 ON l.DocEntry = p1.BaseEntry AND l.LineNum = p1.BaseLine
LEFT JOIN OPOR p ON p1.DocEntry = p.DocEntry
INNER JOIN OCRD c ON o.CardCode = c.CardCode
INNER JOIN CRD1 c1 ON c.CardCode = c1.CardCode AND c.BillToDef = c1.[Address]
LEFT JOIN OCPR cpr ON c.CntctPrsn = cpr.[Name] AND c.CardCode = cpr.CardCode
INNER JOIN OITM itm ON l.ItemCode = itm.ItemCode
INNER JOIN OITB i ON itm.ItmsGrpCod = i.itmsGrpCod
INNER JOIN OSLP s ON o.SlpCode = s.SlpCode
WHERE
o.Canceled = 'N'
AND c1.AdresType = 'B'
AND i.ItmsGrpCod = 109
AND o.DocDate BETWEEN '6/01/2014 00:00:00.000' AND '9/30/2014 00:00:00.000'
ORDER BY
o.DocNum
該ODLN.DocNum與現有的表/列有什麼關係? –
交付單據驗證是否在提交SO時獲得了PO。 – vnguyen
該表與其他人有什麼關係,因此我們可以計算出加入? –