TEXT TO lcSelect NOSHOW TEXTMERGE PRETEXT 15 SELECT * FROM Table1 a LEFT JOIN (SELECT * FROM Table2 WHERE incilog.timestamp IN (SELECT TOP 5 timestamp FROM Table2 aInc WHERE aInc.unitcode = Table2.unitcode AND aInc.unittype= Table2.unittype ORDER BY timestamp DESC)) b ON LTRIM(RTRIM(a.unitcode)) = LTRIM(RTRIM(b.unitcode)) AND LTRIM(RTRIM(a.unittype)) = LTRIM(RTRIM(b.usertyped)) WHERE a.inactive = 'TRUE' and EXISTS ( SELECT * FROM Table1 WHERE inactive = 'TRUE' ) ORDER BY a.unitcode, a.unittype, b.timestamp DESCI am sure there are better ways, but I can't remeber them right now.