Your code worked the first time, without edit. I didn't know about
ROW_NUMBER() OVER ... PARTITION
, so that's a new trick for me. You're right, it seems relatively straightforward with that in hand. But, you also pointed me to some new tools, and to a book's worth of material to read about all the related issues. I don't think there's more that could be done with a single answer. A+++. Would ask again. — David Krider 4 hours ago