This is not bug. It works as the UNION statement is designed. It does not union by column name, but by column order. As long as the types are convertible the values can be unioned. The colum names are taken from the first select statement in the union chain.
In your last statement you get "your expected result", because you do an explicit re-ordering of the columns.
Regards,
Florian
Florian is right. You should also be careful using UNION statement. Check out the difference between UNION and UNION ALL as well.
Add comment