I am new to B1 Query and I am trying to create a report to show a summary of order discounts by customer for a date range. There are discounts at the line level and at the order level. When I run the following query, it adds the order level discount and order level total to the summary for each order line. I can't figure out how to summarize the info from INV1 and pull in the order total info just once per order. Any ideas would be appreciated. Here is my code:
SELECT T1.CardName, sum(T0.QuantityT0.PriceBefDi)[Total Before Discounts], sum((T0.QuantityT0.PriceBefDi)-T0.LineTotal)[Line Discount], Sum(T1.DiscSum)[Order Discount],
Sum(((T0.Quantity*T0.PriceBefDi)-T0.LineTotal)+T1.DiscSum)[Total Discounts],
Sum(T1.TotalExpns)[Freight],Sum(T1.DocTotal)[Invoice Total]
FROM INV1 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry
WHERE T1.DocDate between [%1] and [%2]
Group by T1.CardName
Order By T1.CardName
SELECT T1.CardName, sum(T0.QuantityT0.PriceBefDi) 'Total Before Discounts', sum((T0.QuantityT0.PriceBefDi)-T0.LineTotal)'Line Discount', Sum(T1.DiscSum)'Order Discount',
Sum(((T0.Quantity*T0.PriceBefDi)-T0.LineTotal)+T1.DiscSum)'Total Discounts',
Sum(T1.TotalExpns)Freight,Sum(T1.DocTotal)'Invoice Total'
FROM INV1 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry
WHERE T1.DocDate between '[%1]' and '[%2]'
Group by T1.CardName
Order By T1.CardName
Hi ,
There is one feature on SAP B1 .After you run the query and you want to see the total , you can do
Ctrl+dblclick on the column and you can see the sum of the column .
"I can't figure out how to summarize the info from INV1 and pull in the order total info just once per order."
Can you please explain with specific example ,that will be helpful to specify the desired output you are looking for
Thank you
Bishal
That is a good tip to get the totals! Let's say the OINV file looks like this:
CardNum CardName DocNum DiscSum Doctotal
C0001 Test Cust 22001 15.20 150.20
and INV1 looks like this:
LineNum Item Qty PricebefDi LineTotal
1 Item1 2 25.00 45.00
2 Item2 2 50.00 90.00
I want one summary line that says:
Cust Total before discount Line Discount Order Discount Invoice Total
TestCust 150.00 15.00 15.00 30.00 150.20
Edited by: Phyllis Van Horn on Aug 6, 2008 8:50 PM
Add a comment