@HannahVernon It was telling me that "Please avoid extended discussions in comments..." - so, I hit the link but it just, as I said, dropped me back to the start of the question. But it looks like @bbaird might have rendered further chat moot! :-)
@HannahVernon done, as best I can. It's tricky though. The question is quite involved (which is why I like it! :-) ), but the OP hasn't come back with some responses. I'm not sure if @bbaird 's answer covers all the bases either - it certainly looks impressive, and I'd like to take the time to study it! The problem is that we're undergoing a heatwave here in Ireland (> 30C!!!) and listening to news/politics on the radio in the sun is v. pleasant-plus, try viewing a screen in bright sunshine!
Even having to concentrate in 30C is, well, meh...
@PaulWhite - might be worth reporting as some sort of edge-case bug?
Far more important - db<>fiddle is still down! I bought a disposable credit card specifically to make a donation (don't like the idea of recurring payments and then having to cancel), but you have to dance through lots of hoops to set it up, so I haven't done it yet... It's a bit like an eye infection - you only realise how important something is when it's impaired/removed.
@ypercubeᵀᴹ - does the link not explain it? It has to do with groupings and row_number() - may not be completely appropriate in this case - but hey, it's a cool word! :-) And appropriate for current times! Japanese for "traveller"...
@ypercubeᵀᴹ which seems to apply to OP's problem - at least to an extent! :-) I'm not sure that @bbaird 's solution can't also be written that way - but, as I said, "canicule obilge" - too much effort at the moment! Downstairs talking with Mum... felt heat-stroke kicking in... lovely - great practice for when I go to continental Europe...
@ypercubeᵀᴹ depends - my fiancee wants to go to Florence - I'd prefer Croatia (inland).... Because of my Mother's advanced years, I'd prefer risk reduction...
@FaheemMitha this is a kind of "off-topic - anything goes, chat site"... if you want to ask a "proper" database-related question, then it should be asked on the main site IMHO.