bailun_sku,warehouse_code,SUM(bailun_sku_quantity_ordered) AS bailun_sku_quantity_ordered,SUM(bailun_sku_quantity_pushed) AS bailun_sku_quantity_pushed
bailun_sku,warehouse_code,SUM(bailun_sku_quantity_ordered) AS bailun_sku_quantity_ordered,SUM(bailun_sku_quantity_pushed) AS bailun_sku_quantity_pushed,
sum(case when platform_type = 'Aliexpress' then bailun_sku_quantity_ordered - bailun_sku_quantity_pushed else 0 end) as aliexpress_quantity,
sum(case when platform_type = 'Amazon' then bailun_sku_quantity_ordered - bailun_sku_quantity_pushed else 0 end) as amazon_quantity,
sum(case when platform_type not in ( 'Amazon','Aliexpress') then bailun_sku_quantity_ordered - bailun_sku_quantity_pushed else 0 end) as other_quantity
FROM
dc_base_oms_sku
WHERE
...
...
@@ -544,6 +553,7 @@ SELECT
and bailun_interception_status in('None','Failed')
and warehouse_code != ''
and platform_type != 'FBA'
and company_id = 1
and has_delete = 0
and has_scalp = 0
and has_buyer_remark = 0
...
...
@@ -556,15 +566,16 @@ SELECT
bailun_sku,
warehouse_code
) t1 INNER JOIN dc_base_stock t2 ON t1.bailun_sku=t2.bailun_sku and t1.warehouse_code=t2.warehouse_code
LEFT JOIN dc_auto_jit_inventory t3 ON t1.bailun_sku=t3.bailun_sku and t1.warehouse_code=t3.warehouse_code
LEFT JOIN dc_auto_jit_inventory t3 ON t1.bailun_sku=t3.bailun_sku and t1.warehouse_code=t3.warehouse_code and t3.status = 1