Re: UNION ALL: Apparently based on column order rather than on column name or alias

2018-12-06 Thread Tom Lane
Andreas Schmid writes: > So my conclusion is that the result of UNION ALL depends on the column > order, not on the column names or aliases. Is this the intended > behaviour? Yes, this is required by SQL spec. Matching by column name would be used if you wrote a CORRESPONDING clause, but we don'

UNION ALL: Apparently based on column order rather than on column name or alias

2018-12-06 Thread Andreas Schmid
Hi list I realized the following behaviour of UNION ALL: SELECT 'a' AS col1, 'b' AS col2 UNION ALL SELECT 'c' AS col1, 'd' AS col2; returns: col1 | col2 --+-- a| b c| d Now I switch the column aliases in the second SELECT-Statement: SELECT 'a' AS col1, 'b' AS col2 UNION ALL