>Select ItemNumber, AVG(OnHand*Price) AvgPrice from MyInventory ; >group by ItemNumberWon't be that easy. Rather
Select ItemNumber, sum(OnHand*Price) as totvalue, ; sum(OnHand) as OnStock, 000000000.00 as avgprice from MyInventory ; group by ItemNumber into cursor tmpstock sele 0 use (dbf("tmpstock")) again alias stock repl avgprice with totvalue/onstock for onstock#0The thing is that whenever you have to calculate the average price, you must divide the total value of the stock with the quantity on stock - that is the only way to get what you need.