>>>A SELECT statement doing this is interesting. Just curious what would happen if the closing stock consists of 2 purchases, ie. purchase of 10 @ 12.50 and another purchase of 10 @ 13.00. Out of which only 5 are sold @ whatever rate. Now the closing stock is 15 out of which 5 is @ 12.50 and 10 is @ 13.00.
>>>
>>
>>I asked Tariq to clarify the requirements. He wanted to use the latest rate for the closing stock value. This is what my query is doing. How you'll find out which items were sold otherwise?
>>
>>In other words, using latest rate is the simplest calculation, although I'm not sure how this problem should be solved in accounting. May be someone who deals with lots of similar problems can show the exact formula to use.
>
>Yes, Naomi, what I mentioned above, with my experience in accounting and inventory, is what my requirement would be, that would First-In-First-Out (FIFO) method of stock valuation. Of course there is Avg. and Last-In-First-Out (LIFO) methods too. (update: and many more methods I am sure)
I've seen monthly average too (i.e. closing the values for the month - the month becomes read-only - and anything going out in that month is retroactively valued at this average price in one version; in another, this monthly price applies to the next month).