I am attempting to search on a transaction, and am looking for the total quantity ordered for a single item on the transaction, even if it is broken up between two lines.
For example, Widget A is sold on 2 line items of a Cash Sale (for whatever reason the customer wanted it on two lines) I want the quantities to be summed - ie line 1 there were 16 sold and line 2 there were 4, so show me the Sum of the 2 = 20.
HOWEVER, I am getting 60, consistently. The number of items sold when I am sum the quantity is coming out to 3x the quantity sold on all lines for that item. When I remove the SUM and display each line, I return 16 & 4. So, the query is correct.
Now, I know from my background in SQL (though SQL Server and not Oracle) that when you build a query and it returns a specific rowset, if you add a GROUP BY clause and SUM one of the columns, the results will be as expected - the sum of the quantities that were returned in the original query.
However, this is not working as expected. It is returning the results as they would be if the original query was repeating for some reason over three lines each, and thus summing it as 3*quantity.
PLEASE HELP!!!