select sum(remain_quantity) from tn_grms_stock_record_item where batch_no = 'R202302150002'
select sum(quantity) from tn_grms_stock_record_item where batch_no = 'C202302150002'
-- 撤销记录
-- 入库撤销 展示sum(remain_quantity)
-- 出库撤销 展示sum(quantity)
SELECT
CASE
t1.type
WHEN 1 THEN
sum(t2.remain_quantity)
WHEN 0 THEN
sum(t2.quantity)
END AS sum
FROM
tn_grms_stock_record t1,
tn_grms_stock_record_item t2
WHERE
t1.batch_no = 'C202302150002'
and t2.batch_no = 'C202302150002'
【mysql】select case (type) when 0 ... , when 1 ...根据type字段是0or1,返回不同查询结果实例
最新推荐文章于 2023-08-14 09:43:45 发布