SELECT cus.CustomerName. NVL(sz.OrderDate, {}) AS LastDate, NVL(sz.SizeName, "") AS SizeName FROM Customers cus LEFT JOIN Orders ord ON ord.CustomerID = cus.CustomerID LEFT JOIN Sizes sz ON sz.SizeValue = ord.SizeValue WHERE OrderDate IS NULL OR OrderDate = ( SELECT MAX(OrdeerDate) FROM Orders ord2 WHERE ord2.OrderID = ord.OrderID)>I'm trying to build a cursor that shows all values from the parent cursor, along with the lookup value of the most recent child record. I'm running into difficulties because not all parent records have child records.
Customer1 has 3 orders; Oct 1 for 5000 [Small], Nov 1 for 12000 [Large], Dec 1 for 7000 [Medium] >Customer2 has 0 orders; >Customer3 has 2 orders; Nov 1 for 7000 [Medium], Dec 1 for 11000 [Large] >Customer4 has 1 orders; Oct 1 for 4000 [Small] >Customer5 has 0 orders;>
Customer1 Dec 1 [Medium] >Customer2 {//} [] >Customer3 Dec 1 [Large] >Customer4 Oct 1 [Small] >Customer5 {//} []>