Hi-3736 find mismatch

https://flyzipline.atlassian.net/browse/HI-3736
 avatar
user_0223141589
mysql
a year ago
818 B
1
Indexable
Never
WITH stock_move as 
(
SELECT distinct
sm.PICKING_ID,
pol.PARTNER_ID
FROM BIZ.DBT_STG.STG_ODOO_PROD__STOCK_MOVE sm
join BIZ.DBT_STG.STG_ODOO_PROD__PURCHASE_ORDER_LINE pol on sm.PURCHASE_LINE_ID = pol.ID
group by 1,2
)

SELECT
sp.id,
sp.name,
sp.CREATE_DATE,
sp.PARTNER_ID sp_partner,
ss.ORIGIN_PARTNER_ID ss_partner,
sp.state,
a.partner_id correct_partner
FROM
BIZ.DBT_STG.STG_ODOO_PROD__STOCK_PICKING sp
JOIN BIZ.DBT_STG.STG_ODOO_PROD__SHIPMENT_SHIPMENT ss on sp.SHIPMENT_ID = ss.id
join BIZ.DBT_STG.STG_ODOO_PROD__STOCK_LOCATION sl on sl.id = sp.LOCATION_ID
join BIZ.DBT_STG.STG_ODOO_PROD__STOCK_LOCATION sl2 on sl2.id = sp.location_dest_id
join stock_move a on a.picking_id = sp.id
where sp.PARTNER_ID != a.partner_id
and sp.state not in ('done','cancel')
and sl.USAGE in ('supplier')
and sl2.WAREHOUSE_ID in (16,30)