08-23-2017 2:24 AM - edited 02-04-2024 1:10 AM
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
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]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
9 | |
8 | |
5 | |
4 | |
3 | |
3 | |
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.