筛选拆单后订单状态全部为已取消状态的订单有哪些
背景
用户下单之后,我们会按照发货仓库进行拆单,即一个父订单可能会对应过个子订单。现在有一个场景需要查询有哪些父订单下的子订单是全部都被取消的,订单的取消状态为99。
筛选拆单后订单状态全部为已取消状态的订单有哪些?
select parent_order_no,t.total_qty, t.99_qty from ( select parent_order_no,count(*) as total_qty,sum(case when order_status = 99 then 1 else 0 end) as 99_qty from order_main where order_type = 3 group by parent_order_no ) t where t.total_qty = t.99_qty
本篇文章如有帮助到您,请给「翎野君」点个赞,感谢您的支持。
出处:http://www.cnblogs.com/lingyejun/
若本文如对您有帮助,不妨点击一下右下角的【推荐】。
如果您喜欢或希望看到更多我的文章,可扫描二维码关注我的微信公众号《翎野君》。
转载文章请务必保留出处和署名,否则保留追究法律责任的权利。