MySQL 8.0的基于CALC FIFO的库存评估

发布于 2025-01-23 23:53:03 字数 1916 浏览 5 评论 0原文

所有人的美好一天。 我花了三天多的时间进行搜索和测试,但没有任何帮助。 让我们假设我有很多方法可以将产品项目输入存储,所以我创建了“视图”以向我展示“这样的产品交易”,例如:

product_idstorage_idtypeunit_cost nouts_cost82数量
1in1102022-04-2517 :04:13
821in2102022-04-25 17:04:51
821in3102022-04-25 17:07:13
8216in2102022-04-25 17:10:51
8216in3102022-04-25 17:12:13

我还通过订单(订单和订单项目表查看)

product_idstorage_id日期
821152022-04-25 17:06:06:
27 82172022-- 04-25 17:08:24
82252022-04-25 17:20:13

因此,从这些表和视图中,是否有任何询问我的库存评估(未出售商品成本),并根据FIFO和lifo 该查询应显示如下(FIFO):

product_idstorage_id剩余_quantitytotal_cost
821824
82161540

(lifo):

product_idstorage_idre re re re re re re re retaning_quantitytotal_cost
821814
82 161515 3535

nice day for all.
I spent more than three days of searching and testing but nothing helped me.
let us assume I have many way to enter items of product to storages, So I created 'view' to show me the product transactions "in" like this:

product_idstorage_idtypeunit_costquantitydate
821in1102022-04-25 17:04:13
821in2102022-04-25 17:04:51
821in3102022-04-25 17:07:13
8216in2102022-04-25 17:10:51
8216in3102022-04-25 17:12:13

also I sold items by orders (order and order items tables view)

product_idstorage_idquantitydate
821152022-04-25 17:06:27
82172022-04-25 17:08:24
82252022-04-25 17:20:13

so from these tables and views, is there any query to calc my inventory valuation (cost of goods didn't sold) based on FIFO and LIFO
that query should show data as follow(FIFO):

product_idstorage_idremaining_quantitytotal_cost
821824
82161540

(LIFO):

product_idstorage_idremaining_quantitytotal_cost
821814
82161535

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文