>OK Cetin,
>First, let me tell you how much I appreciate the assistance. This SQL is above my pay grade.
>
>We are soooo close. Obviously I have not been clear enough.
>
>You are getting the latest OPEN transaction per inmate. That's helpful but not exactly what I need.
>
>Inmate 0012345 should not show in the cursor. Why? His latest transaction is a "CLOSED". Only the inmates where the latest transaction is an "OPEN" should show in the cursor. So what I am after is a list of inmates that are currently OPEN.
>
>Having said all that, I could be doing something wrong. Please correct me if I am.
>Thanks,
>John
John,
How about this:
SELECT cInmate_Number, tTxnDateTm, TxnStatus ;
FROM INMATES im ;
LEFT JOIN ACCT_EVENTS ae ;
ON im.cID = ae.cInmates_ID ;
WHERE tTxnDateTm IN (SELECT MAX(tTxnDateTm) FROM ACCT_EVENTS GROUP BY cInmates_ID) ;
AND TxnStatus = 'OPEN'
Then, just substitute a view parameter variable for 'OPEN' and I believe you will have what you are looking for.
_________________________________
There are 2 types of people in the world: