1 . Ejecutar query «FLEET – IDENTIFICA ORDENENTREGATIENDA CON ESTATUS EN TRANSITO – EN LUGAR DE ENTREGADO»
— FLEET – IDENTIFICA ORDENENTREGATIENDA CON ESTATUS EN TRANSITO – EN LUGAR DE ENTREGADO —
SELECT oe.tiendaremisionid AS ‘Tienda Remision’, oe.noorden AS ‘Orden’, oet.TiendaID AS ‘Tienda Entrega’, e.Nombre AS ‘Estatus Tienda’, e2.Nombre AS ‘Estatus Orden’, oe.OrdenEntregaID
FROM ordenentrega oe WITH(NOLOCK)
INNER JOIN ordenentregatienda oet WITH(NOLOCK) ON oet.ordenentregaid = oe.ordenentregaid
–AND oet.tiendaid IN (8763)
AND oet.EstatusOrdenEntregaID IN (7) — EN TRANSITO
LEFT JOIN EstatusOrdenEntrega e WITH(NOLOCK) ON e.EstatusOrdenEntregaID = oet.EstatusOrdenEntregaID
LEFT JOIN EstatusOrdenEntrega e2 WITH(NOLOCK) ON e2.EstatusOrdenEntregaID = oe.EstatusOrdenEntregaID
WHERE oe.fechaventa >= ‘2024-01-01’ AND oe.EstatusOrdenEntregaID IN (8) — ENTREGADO
AND (NOT EXISTS(SELECT 1 FROM ordenentregaarticulo oea WITH(NOLOCK) WHERE oea.ordenentregaid = oe.ordenentregaid AND oea.TiendaEntregaID = oet.TiendaID AND oea.EstatusArticuloID IN (7)))

2 . Ejecutar select por filtro de Ordenentregaid y TiendaID por cada registro obtenido en el punto 1
SELECT *
FROM OrdenEntregaTienda WITH(NOLOCK)
WHERE OrdenEntregaID IN (18281234) — Ordenentregaid
AND TiendaID IN (8663) — Tienda Entrega
se consulta ordeneentregaid y tienda entrega con query SelectOrden_Split081220

se confirma que el estatusordenentregaID esta en “7”

3.- Actualizar «Where» del query de actualización con OrdenEntregaID y TiendaID del punto 2 y ejecutar el update

4.- Ejecutar nuevamente el punto 1 para validación de que el registro quedó mitigado (Ya no debe de aparecer) y cambia el estatus del paso 2 “ estatus ordenentrega ID a “8”
