工作记录(8)

 SELECT *, (current_qty-(case when occupied_qty is null then 0 else occupied_qty end)) overdosage_qty from (
            SELECT log.id as id, log.location_id, log.product_id, p.fullcode, p.categ_grade_one, p.categ_grade_two, p.categ_grade_three, log.balance_qty current_qty, p.product_uom as product_uom_id, 
(select sum((lot.product_qty-lot.welded_qty)*bom_line.product_qty) from stock_production_lot lot join  product_bom bom on lot.product_id = bom.product_id and lot_type = 'outsourcing_lot' and lot.state = 'plan' join product_bom_line bom_line on bom.id = bom_line.bom_id where bom_line.product_id=p.id and lot.src_location_id=log.location_id) as occupied_qty
  from product_product p join stock_product_cost_log log on p.id = log.product_id and log.end_time >= '4000-12-31' 
  where log.location_id in (select id from stock_location where usage='internal' and location_type='outsourcing_workshop')) t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值