Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Average Price of an Item
Message
From
29/09/1997 10:15:00
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00051801
Message ID:
00052155
Views:
36
>>The problem is, I dont want to store this price with the Item in the >product file because the purchase voucher and the issue vouchers may be >ammended at any time. This will offset the price. Now at the end of the >month they want to evaluate the stock, can I write a simple SQL statement >and get the avg price of each item? >If your table looks something like: > >ItemNumber OnHand Price >101 3 5.00 >101 100 3.00 >102 21 7.50 >102 30 10.00 >102 20 9.00 > >You could try:
>Select ItemNumber, AVG(OnHand*Price) AvgPrice from MyInventory ;
>group by ItemNumber
Won'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#0
The 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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform