Hi Laurenz, and thanks for your contribution,
> > ERROR: column t1.englmark does not exist LINE 19: AND t1.englmark = t2.maxmark
> You cannot refer to a column alias in a WHERE condition,
> because grouping takes place *after* the WHERE condition
> has been evaluated.
Yes - of course! And nor can I refer to an aggregate! Thanks for
pointing out what I should have known at this stage! I'm putting it
down to late-night fatigue yesterday.
I'm just wondering if there are significant performance implications
associated with deeper levels of nesting?
I was attempting to look at using Window/Analytic functions to get
this done, but I just can't see it. I think that your solution (and
explanation) is optimal for this particular use case - a PIVOT (pity
it's not available by default in PostgreSQL!) is essential and there's
no (what I see as) a more elegant way.
Thanks again for your input,
Regards,
Pól...
> Laurenz Albe