SQL 语句关联函数查询进销存多次入库剩余数量统计

编程入门 行业动态 更新时间:2024-10-10 15:17:50

SQL 语句关联函数查询<a href=https://www.elefans.com/category/jswz/34/1768018.html style=进销存多次入库剩余数量统计"/>

SQL 语句关联函数查询进销存多次入库剩余数量统计

SQL 语句关联函数查询进销存多次入库剩余数量统计,一个采购订单可以多次入库,每次入库时需统计之前该采购订单的每个物品已经入库了多少数量,还剩余多少数量需要入库,录入入库数量时需进行校验,不能大于剩余入库数量,

无批次

SELECT t.material_number, t.count, ISNULL(d.sumincount,0) AS sumincount, (t.count- ISNULL(d.sumincount,0)) AS diffCount
FROM t_store_apply_detail t
LEFT JOIN (
SELECT sid.material_number, SUM(sid.count) AS sumincount
FROM t_store_stockin_detail sid
LEFT JOIN t_store_stockin si ON sid.main_id = si.fID
WHERE si.store_apply_number='a_20170824_1'
GROUP BY sid.material_number) d ON t.material_number = d.material_number
WHERE t.store_apply_number = 'a_20170824_1'
-- and (t.count-isnull(d.sumincount,0)) > 0
ORDER BY t.apply_item_number ASC


带库存批次查询

SELECT t.material_number, t.count, ISNULL(d.sumincount,0) AS sumincount, (t.count- ISNULL(d.sumincount,0)) AS diffCount
FROM t_store_apply_detail t

更多推荐

SQL 语句关联函数查询进销存多次入库剩余数量统计

本文发布于:2024-02-06 09:06:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1748042.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进销存   语句   函数   剩余   数量

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!