Thanks for the tips - unfortunately, I don't think either one will work for me. I'm using DB2 on the mainframe OS/390, and it does not support the ROW_NUMBER OLAP function.
The second suggestion would probably work in a stored procedure, but I need to come up with a simple SQL query that I can...