Assuming we have a UNION ALL query from two sub queries with different column names just like:
SELECT colName1 FROM table1
SELECT colName2 FROM table2
In other databases, this returns a result set whose column is colName1 which is the same as the column listed in the first subquery.
But in DB2ZOS, it seems the columns are numbers like 1,2,3,4.
The question is if I want to wrap the UNION ALL query into an outer SELECT statement, How should I list the new column names? Is there a configuration to make DB2ZOS consistent with others
Pinned topic The column name generated in UNION ALL
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-01-05T08:27:16Z at 2013-01-05T08:27:16Z by SystemAdmin
SystemAdmin 110000D4XK3105 Posts
Re: The column name generated in UNION ALL2013-01-05T08:27:16ZThis is the accepted answer. This is the accepted answer.you can just alias your columns anyway you want
select colname1 as my_special_column from table1
select colname2 from table2
the result table should have a column named my_special_column