sum(t1.quantity_init_advise) as 'quantity_init_advise', -- 原始采购建议数量 new
sum(t1.quantity_init_advise) as 'quantity_init_advise', -- 原始采购建议数量 new
( sum(t1.quantity_out_stock) - ( sum(t1.quantity_inventory) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
( sum(t1.quantity_out_stock) - ( sum((case when t1.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
t6.product_inner_code as 'product_inner_code', -- 内部商品编码 new
t6.product_inner_code as 'product_inner_code', -- 内部商品编码 new
0 as 'goods_quantity_init_advise', -- 商品本次的建议下单数量 new
0 as 'goods_quantity_init_advise', -- 商品本次的建议下单数量 new
0 as 'goods_moq', -- 商品的moq new
0 as 'goods_moq', -- 商品的moq new
...
@@ -128,7 +128,7 @@ select
...
@@ -128,7 +128,7 @@ select
where t6.buyer_name in ('赵美聪','张莹霞','张莹霞1','冯兆欣')
where t6.buyer_name in ('赵美聪','张莹霞','张莹霞1','冯兆欣')
and t1.warehouse_code in ('GZBLWH','GZBLYS')
and t1.warehouse_code in ('GZBLWH','GZBLYS')
GROUP BY t1.bailun_sku
GROUP BY t1.bailun_sku
HAVING ( sum(t1.quantity_inventory) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t1.quantity_out_stock) )
HAVING ( sum((case when t1.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t1.quantity_out_stock) )