This is a great solution. But the only hitch is that if "a" has
repeating values the counter goes for a toss. However , I love how the
inner query is structured. The solutions is go good that I want to
change the problem to fit it

But, alas, I am still stuck where I
was.