Skip to Content
0
Jul 15, 2020 at 06:24 AM

SAP querie last sold item doesn't show all items

43 Views

Hi,

Can someone please help me with this querie.

I want this querie to display ALL the items. Also the items that are not sold. Now it displays only items that are sold with an order or invoice. I thought LEFT JOIN would do the trick but it doesn't.

SELECT 
T0.[ItemCode], 
T0.[ItemName], 
T1.[WhsCode], 
MAX(T1.[ShipDate]) as 'Last sold on order',
MAX(T1.[ActDelDate]) as 'Last sold on invoice'


FROM 
OITM T0  
LEFT JOIN 
INV1 T1 
ON T0.[ItemCode] = T1.[ItemCode] 


WHERE
T1.[WhsCode] =[%0]


GROUP BY
T0.[ItemCode], 
T0.[ItemName], 
T1.[WhsCode]