Suppose I have a table called spitems with the following fields:
- spitemid (unique key)
- modifiedon (timestamp)
- parentid
- a number of other unsignificant fields
What I want to retrieve, is the spitem rows with the highest modifiedon day for each parentid.
However, be aware that the modifiedon timestamp is not unique, so it is possible that for one parent id, there are two spitemids with the same modifiedon timestamp. In that case, I need one of these two spitemids listed, I don’t care which one.
So to be clear: the list I return should contain all the parentids once and only once.
update
meeting over, here is my shot:
old entry
not sure if this is different on DB2, here it is for sql server.
hmm… this will return more than one for the dups… can’t fix it now, have to go to a meeting.