>select a.cid, a.cinmate_number, ; > b.cinmates_id, b.ttxndatetm, b.txnstatus ; > from INMATES a ; > inner join ACCT_EVENTS b ; > on a.cid = b.cinmates_id ; > where ttoc(b.ttxndatetm,1) = ; > (select max(ttoc(ttxndatetm,1)) from ACCT_EVENTS c ; > where b.cid = c.cid and c.txnStatus= 'OPEN') >>Thanks,
select a.cid, a.cinmate_number, ; b.cinmates_id, b.ttxndatetm, b.txnstatus ; from INMATES a ; inner join ACCT_EVENTS b ; on a.cid = b.cinmates_id ; where ttoc(b.ttxndatetm,1) = ; (select max(ttoc(ttxndatetm,1)) from ACCT_EVENTS c ; where b.cinmates_id = c.cinmates_id and c.txnStatus= 'OPEN')If you mean to return only one record remove 'b.cinmates_id = c.cinmates_id and'