Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2801

Query multiple deliveries from single sales order

$
0
0

Hello,

 

I have a hard time to write a query to output all single sales orders with multiple deliveries. So far I came up with the following query.

 

SELECT DISTINCT T0.CardCode, T0.[CardName],T1.[Dscription], T2.Quantity AS [Delivery Qty],  T3.docnum 'Delivery #' ,  T5.docnum AS 'Invoice #', T1.[Quantity] AS [SO Qty],  T0.[DocNum] AS 'SO #', T5.DocDate, COUNT(*)

 

FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry LEFT join DLN1 T2 on T2.baseentry = t0.docentry and t1.linenum = T2.baseline LEFT join ODLN T3 on T3.docentry = T2.docentry LEFT JOIN INV1 T4 ON T4.BaseEntry=T3.DocEntry LEFT JOIN OINV T5 ON T5.DocEntry=T4.DocEntry

 

GROUP BY T5.docnum, T2.Quantity, T3.docnum, T0.CardCode, T0.[CardName],T1.[Dscription],T1.[Quantity], T0.[DocNum], T5.DocDate

 

Having COUNT(*) > 1

 

I am not sure this would solve the problem.

 

Thank you for your help.

 

--Bill


Viewing all articles
Browse latest Browse all 2801

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>