This pulls all inactive records in untype and the matching records in incilog as it should:
lcSelect = "SELECT " ;
+" * " ;
+" FROM Table1 a LEFT OUTER JOIN Table2 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 untype WHERE inactive = 'TRUE' ) ";
+" ORDER BY a.unitcode, a.unittype, b.timestamp DESC "
However, my goal now is to pull all records in Table1 that have inactive = 'true' (whether or not there is a matching record in Tabl2) but only pull the top 5 matching records in Table2 by timestamp descending (the 5 most recent records in Table2) for each record pulled in Table1 (if any matching records exist in Table2). I am stumped this morning, ideas?
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"