Re: Why oh why is this join not working?
Pól Ua Laoínecháin <[email protected]> Mon, 18 Nov 2019 11:39:12 +0000
| Newsgroups | gmane.comp.db.postgresql.novice |
|---|---|
| Message-ID | <CAF4RT5Qqi6LPvHzK-_ZO78awguVJ5ux3FTqC_Z6T-A6LocN4Ug@mail.gmail.com> |
Hi Laurenz, and thanks for your contribution, > > ERROR: column t1.englmark does not exist LINE 19: AND t1.englmark =3D t= 2.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=C3=B3l... > Laurenz Albe