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

Re: Compare offered vs sold by category

$
0
0

What are you looking for? Try this one:

 

Select T0.CardCode,T0.CardName,T9.ItmsGrpNam,

T1.ItemCode, Max(T1.Dscription) 'Item name',

SUM(T1.Price * T1.Quantity) AS Offered,SUM(T7.Price * T7.Quantity) AS Sold

From OQUT T0 inner join QUT1 T1 On T1.DocEntry=T0.DocEntry

JOIN OITM T2 ON T2.ItemCode=T1.ItemCode

JOIN OITB T9 ON T9.ItmsGrpCod=T2.ItmsGrpCod

   left join RDR1 T3 on (T1.TrgetEntry=T3.DocEntry and T1.TargetType=17 and T3.BaseLine=T1.LineNum)

left join ORDR T4 on T4.DocEntry=T3.DocEntry

   left join DLN1 T5 on T3.TrgetEntry=T5.DocEntry and T3.TargetType=15 and T5.BaseLine=T3.LineNum

left join ODLN T6 on T6.DocEntry=T5.DocEntry

   left join INV1 T7 on (T5.TrgetEntry=T7.DocEntry and T5.TargetType=13 and T7.BaseLine=T5.LineNum)

Left join OINV T8 on T8.DocEntry=T7.DocEntry

GROUP BY T0.CardCode,T0.CardName,T9.ItmsGrpNam,T1.ItemCode


Viewing all articles
Browse latest Browse all 9236

Trending Articles