Home > database >  How to implement the weighted average unit price calculation using mysql
How to implement the weighted average unit price calculation using mysql

Time:01-30


Everyone a great god, and I ask you how to use mysql to achieve above red columns of weighted average unit price calculation?

The inventory of the unit price is the purchase price, dispatch unit price is the sale price; Outbound, the weighted average unit price will not change, each incoming weighted average unit price need to recalculate the calculation is as follows:

Such as: id for 5 items, four 2019.7.7, warehousing, storage unit price is 207, weighted average price of 207;

10 2019.7.9, warehousing, storage unit price is 202, weighted average price for (207 * 4 + 202 * 10)/(1 + 4)=203.4285714;

10 2019.7.12, warehousing, storage unit price is 208, weighted average price for (11 + 208 * 203.4285714 * 10)/(4 + 10-3 + 10)=205.6054422

So on that,
  • Related