Calculating the Weighted Average Cost of products stock

前端 未结 5 1545
甜味超标
甜味超标 2020-12-28 23:12

I have to calculate my products stock cost, so for every product after each buy, i have to recalculate the Weighted Average Cost.

I got a view thats

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 00:02

    There already is a aggregate function in C for PostgreSQL available, and it will probably calculate much faster than any solution in SQL:

    https://github.com/Kozea/weighted_mean

提交回复
热议问题