Quantcast
Viewing all articles
Browse latest Browse all 9052

Re: Sales by Item in Sap Bo

Thanks for your help, Paul

 

We have Credit Notes not related to Invoices, so i had to use DocDate, CardNum, ItemCode as key

 

The Final query i  got is:

 

 

SELECT       DocDate, CardCode, CardName, ItemCode, Dscription,                              SUM(Quantity) AS Quantity, U_KGSXPZA, Quantity * U_KGSXPZA AS Expr1

FROM            (SELECT        T0.DocDate, T0.CardCode, T0.CardName, T1.ItemCode, T1.Dscription, T1.Quantity, T2.U_KGSXPZA

                          FROM            dbo.OINV AS T0 INNER JOIN

                                                    dbo.INV1 AS T1 ON T1.DocEntry = T0.DocEntry INNER JOIN

                                                    dbo.OITM AS T2 ON T1.ItemCode = T2.ItemCode

                          WHERE      (T0.DocType = 'I')

                          UNION ALL

                          SELECT        T0.DocDate, T0.CardCode, T0.CardName, T1.ItemCode, T1.Dscription, - T1.Quantity AS 'Quantity', T2.U_KGSXPZA

                          FROM            dbo.ORIN AS T0 INNER JOIN

                                                   dbo.RIN1 AS T1 ON T1.DocEntry = T0.DocEntry INNER JOIN

                                                   dbo.OITM AS T2 ON T1.ItemCode = T2.ItemCode

                          WHERE        (T0.DocType = 'I')) AS S

GROUP BY DocDate, CardCode, CardName, Dscription, ItemCode, U_KGSXPZA, Quantity * U_KGSXPZA

ORDER BY 'Quantity' DESC

 

Regards!!


Viewing all articles
Browse latest Browse all 9052

Trending Articles



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