Skip to Content

Query total discount applied in sales orders.

Aug 23, 2017 at 01:24 AM


avatar image

We need to make a query that shows the total discount of the sales orders. The problem is that sales order discounts in our company are made by lines.Contagem de

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Balaji Selvaraj Aug 23, 2017 at 05:27 AM

Hi Cristian,

Try this

SELECT Distinct T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], Sum(T1.[DiscPrcnt]) [Total Discount %], Sum(T1.[LineTotal]) [TotalAmount With Disc] , Sum((T1.[Quantity] * T1.[PriceBefDi]))[TotalAmount Without Disc]  ,(Sum((T1.[Quantity] * T1.[PriceBefDi])) - Sum(T1.[LineTotal]))[Total Discount]  FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry] WHERE T0.[DocDate] >=[%0] AND  T0.[DocDate] <=[%1]
Group By T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal]

10 |10000 characters needed characters left characters exceeded