|
The attached example column-headings-minimal.sql produces duplicate column-headings despite the fact that the first column is configure with AS col_one.
It seems that the relevant parts which trigger this (unexpected?) behaviour are:
- join with a subquery
- the sub-query contains an IFNULL or COALESCE
- the outer query uses GROUP BY (remove it and the problem is no longer there)
- it does not matter where one uses a "real" table or this virtual "seq_1_to..." tables
- the second attached SQL example column-headings-less-minimal.sql shows some more columns with IFNULL in addition to COALESCE and also selects the "vanilla" sequence column.
The example itself is "brain-damaged" of course, but I stumbled over this in a context where the SQL query is programmatically generated. I also think that whatever you do in the sub-query should not affect the column names of the outer query.
|