select cs.*, AH.* > from customer cs > LEFT OUTER JOIN activityhistory AH > on AH.customerid = cs.customerid > AND ah.inserteddatetime IN ( SELECT MAX(inserteddatetime) > from activityhistory AH2 > where AH.customerid = ah2.customerid) >>>Okay I have a customer table with a child table with multiple records.
>>select customerid, AH.* from customer >> LEFT OUTER JOIN (select top 1 customerid, agentid, inserteddatetime >> from activityhistory AH >> where AH.customerid = customer.customerid >> order by inserteddatetime desc ) >> on AH.customerid = customer.customerid >>>