--includes very recent shipments that SL hasn't reported yet
with sl_ecomm as (
select
distinct
[order_id]
from analytics.dbo.SL_ECOMM
)
select
eso.order_number,
cast(eso.created_at as date)[creation/payment date],
cast(eso.updated_at as date)[fulfilled date],
isnull(sl_ecomm.order_id,'no') [received data from Source],
isnull(SOH.SOHNUM_0,'none') [X3 Sales order]
from staging.dbo.ecommerce_shipped_orders eso
left join sl_ecomm
	on eso.order_number = sl_ecomm.order_id
left join x3.PROD.SORDER SOH
	on eso.order_number = SOH.CUSORDREF_0
	and SOH.SOHTYP_0 = 'WEB'
where 
SOH.SOHNUM_0 is null
--sl_ecomm.order_id is null
and eso.updated_at >= '6-1-2024'
and eso.order_number not in ('351445','486270','482841','485954','450287','514490')
order by 2 desc