on 2020 Aug 17 7:24 AM
Hi all,
I'm new to SQL and I managed to create a Sales Order vs AR Invoice query. However, when I try to include the Items Group Code into the query, it tells me that the multi-part identifier "T6.ItmsGrpCod' could not be bound. This is the code I used that works.
SELECT T0.[DocDate], T0.[DocNum] as 'Sales Order No.', T0.[CardName], T9.[SlpName] AS 'Sales Employee', T0.[U_Class], T1.[ItemCode], T1.[Dscription], T1.[Quantity] as 'SO Qty', T1.[OpenQty] as 'SO Open Qty', T0.DocStatus as 'SO Status', T0.[CANCELED] AS 'Canceled', T3.[Quantity] as 'Delivered Qty', T3.[OpenQty] as 'Delivered Open Qty', T4.[Quantity] as 'Invoice Qty'
FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry] left join DLN1 T2 on T2.baseentry=T1.docentry and T2.itemcode=T1.itemcode left join inv1 T3 on T3.baseentry=T2.docentry and T3.itemcode=T2.itemcode left join inv1 T4 on T4.baseentry=T1.docentry and T4.itemcode=T1.itemcode left outer join OSLP T9 on T9.SlpCode = T1.SlpCode
Request clarification before answering.
Hi,
The above query is OK, if only one line item in sales order, DO and AR invoice. If more than one line item, then we have to add line number to get correct result.
Try this,
SELECT T0.[DocDate], T0.[DocNum] as 'Sales Order No.', T0.[CardName], T9.[SlpName] AS 'Sales Employee', T0.[U_Class], T1.[ItemCode], T1.[Dscription], T1.[Quantity] as 'SO Qty', T1.[OpenQty] as 'SO Open Qty', T0.DocStatus as 'SO Status', T0.[CANCELED] AS 'Canceled', T3.[Quantity] as 'Delivered Qty', T3.[OpenQty] as 'Delivered Open Qty', T4.[Quantity] as 'Invoice Qty', T6.[ItmsGrpCod] as 'Item Group'
FROM
ORDR T0 INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN OITM T5 ON T5.ItemCode = T1.ItemCode
left join DLN1 T2 on T2.baseentry=T1.docentry and T2.itemcode=T1.itemcode and T2.Baseline = T1.lineNum
left join inv1 T3 on T3.baseentry=T2.docentry and T3.itemcode=T2.itemcode and T3.Baseline = t2.LineNum
left join inv1 T4 on T4.baseentry=T1.docentry and T4.itemcode=T1.itemcode and T4.Baseline = t1.LineNum
left Join OITB T6 on T6.[ItmsGrpCod] = T5.[ItmsGrpCod] left outer join OSLP T9 on T9.SlpCode = T1.SlpCode
Regards,
Nagarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.