Why is the order of tables important when combining an outer & an inner join ? the following fails with postgres:
SELECT grp.number AS number,
I don't think anyone's quite nailed this, or explained it very well. You're combining 'old style' (theta) and 'new style' (ANSI) joins, which I strongly suspect are being grouped in ways you don't expect. Look at it this way:
SELECT * FROM a, b JOIN c ON a.x = c.x
is like saying
SELECT * FROM a, (b JOIN c on a.x = c.x)
where the bracketed thing represents a bunch of tables merged into one virtual table, to be joined on with a theta-join against 'a'. Obviously the 'a' table can't be part of the join as it's only being joined onto later. Reverse it, and you're doing
SELECT * FROM b, (a JOIN c on a.x = c.x)
which is perfectly understandable and so fine. I'm not sure why you're not using ANSI join syntax for all of it though, seems a little weird (and cruel to the person who has to maintain it!)