Rich, Dave, Federico ---
Guys, for the assist! The last piece of the puzzle follows.
A buddy of mine in Pennsylvania was able to force the date comparison.
Rich, this is pretty close to your code, a couple of minor diffs
do the job!
SELECT tr_id, tr_date
FROM crtrd1 ALIAS1
WHERE ALIAS1.tr_unit = 'SMA'
AND (ALIAS1.tr_type = 'A' OR ALIAS1.tr_type = 'I')
AND NOT EXISTS(
SELECT tr_id
FROM crtrd1 ALIAS2
WHERE ALIAS2.tr_unit = 'SMA'
AND ALIAS2.tr_id = ALIAS1.tr_id
AND (ALIAS2.tr_type = 'T' OR ALIAS2.tr_type = 'O')
AND ALIAS2.tr_date > ALIAS1.tr_date
)
ORDER BY tr_date DESC;
Thanks for your assistance boys - I'm thinking of getting this
tattooed somewhere - somewhere I can see it when I need it that is!
---------- Sisters of Charity Medical Center ----------
Department of Psychiatry
----
Thomas Good <tomg@q8.nrnet.org>
Coordinator, North Richmond C.M.H.C. Information Systems
75 Vanderbilt Ave, Quarters 8 Phone: 718-354-5528
Staten Island, NY 10304 Fax: 718-354-5056