Need some help with linking of invoice to their deliveries. I am using below query but seems like its not giving me correct output.
SELECT T0.[DocNum] as 'Del DocNum', T0.[DocDate] as 'Del DocDate', T3.[DocNum] as 'Inv Docnum', T3.[DocDate] as 'Inv Docdate' FROM ODLN T0 INNER JOIN DLN1 T1 ON T0.[DocEntry] = T1.[DocEntry] left join INV1 T2 on T2.[BaseEntry] = T1.Docentry and T2.[BaseLine] = T1.[LineNum] INNER JOIN OINV T3 ON T2.[DocEntry] = T3.[DocEntry] WHERE T0.[DocDate] between [%0] and [%1] group by T0.[DocNum], T0.[DocDate],T3.[DocNum], T3.[DocDate]