Hello Richard,Hello Andre,I did some testing and after all your query should be ordered right.
The test's I have done:Test=# select t.foo1 from testtable t
Test-# union
Test-# select t.foo2 from testtable t
Test-# order by t.foo1;
ERROR: Relation 't' does not exist-------- Same error as you get ----
Test=# select t.foo1 from testtable t
Test-# union
Test-# select t.foo2 from testtable t
Test-# order by foo1;
foo1
------
abc
cdef
(2 rows)-------- Ordered Ascending (maybe by chance?) ---
Test=# select t.foo1 from testtable t
Test-# union
Test-# select t.foo2 from testtable t
Test-# order by foo1 DESC;
foo1
------
cdef
abc
(2 rows)---- Ordered descending (ordering works!) ---
I guess, the table-alias is not known to the order-clause. Maybe the
execution (or parsing) order of the UNION changed from 7.0 to 7.1.
Thanks very much for having tested. Yes, it works well.
-- Richard NAGY Presenceweb