Buen día a todos.
Estoy diseñando una query que arroje la trazabilidad desde la oferta de venta hasta la entrega, para lo cual me basé en un tema anterior resuelto en el foro, gracias a esto obtuve la siguiente query:
SELECT
distinct 'Materiales' as "Tipo" ,
T0."CardCode" as "Código cliente", T0."CardName" as "Nombre cliente",
T2."DocNum" as "N° Oferta de venta" , T2."DocDate" as "Fecha Oferta de venta", T2."CANCELED" as "Estatus Orden de venta",
T2."DocTotal" as "total OV", T2."DocCur" as "moneda",
T0."NumAtCard" as "N° OC",T0."DocEntry" as "Orden de venta", T0."DocNum" as "Numero Entrega" , T0."CANCELED" as "status Entrega",
T0."DocDate" as "Fecha de Entrega", T0."DocTotal",T0."DocCur" as "moneda",
T4."DocEntry" as "Entrega",T4."DocNum" as "N° de Factura",
T4."DocDate" as "Fecha Factura" , T4."CANCELED" as "status Fac",
T4."DocTotal" as "total factura",T4."DocCur" as "moneda"
from ORDR T0
inner join RDR1 T1 on T1."DocEntry" = T0."DocEntry" and T1."BaseType" in('23') and T1."TargetType" in ('15','-1') and T1."LineNum"=0
inner join OQUT T2 on T2."DocEntry" = T1."BaseEntry"
inner join QUT1 T5 on T2."DocEntry" = T5."DocEntry"
left join DLN1 T3 on T1."TrgetEntry" = T3."DocEntry"
left join ODLN T4 on T4."DocEntry" = T3."DocEntry"
De esta query me hacen falta las Oferta de venta que no se transformaron en Ordenes de venta, favor solicito su ayuda con esto último.
Desde ya muchas gracias.