I have a problem in query data from database to make report in VB.NET. I use the Business Object to do the report. And here is my example data:
___________________________________________________________________________
| | | | | | |
| Id | Item | Unit | Unit Price | Quantity | Amount |
|____|_______________|__________|_____________|___________|_______________|
| 1 | Gasoline | L | $ 2.00 | 10 | $ 20.00 |
| 1 | Gasoline | L | $ 2.50 | 20 | $ 50.00 |
| 2 | Water | Bottle | $ 5.00 | 10 | $ 50.00 |
| 3 | Meat | Kg | $ 14.90 | 15 | $ 223.50 |
| 1 | Gasoline | L | $ 8.00 | 50 | $ 400.00 |
| 4 | Milk | Can | $ 7.45 | 30 | $ 223.50 |
| 1 | Gasoline | L | $ 6.99 | 10 | $ 69.90 |
|____|_______________|__________|_____________|___________|_______________|
In report, I want to see the "Id" , "Item" , "Unit" , "Unit Price" (And yes, this one I will show "Undefined" instead if they have the different value), "Quantity" (Sum of the same item) and "Amount" (Sum of the same item). But I have tried a few times, the result is wrong. How to calculate the "Amount" all the same item, if their "Unit Price" are not the same price at all. Here is my expected result:
___________________________________________________________________________
| | | | | | |
| Id | Item | Unit | Unit Price | Quantity | Amount |
|____|_______________|__________|_____________|___________|_______________|
| 1 | Gasoline | L | Undefined | 90 | $ 539.90 |
| 2 | Water | Bottle | $ 5.00 | 10 | $ 50.00 |
| 3 | Meat | Kg | $ 14.90 | 15 | $ 223.50 |
| 4 | Milk | Can | $ 7.45 | 30 | $ 223.50 |
|____|_______________|__________|_____________|___________|_______________|
Please help me....
Amount
is justUnit Price * Quantity
. This could be done in a database view, in a SQL statement, in a business object, in a UI view, etc. – Greeunit_price
? I believe you want to show the correct unit_price in that case ;) – Ebberta