I have a simple sql statements as below
CASE 1:
select 1 as a
union
select 2 as a
Output: This case is working as expected
CASE 2:
select 1 as a
union
select 2 as b
Output: Though the alias is 'b' in my second select, it still shows the alias 'a'.
Why cant it take the alias from the second select statement?
How can we make sql to choose the alias from the second select query?
CASE 3:
select 1
union
select 2 as b
Output: Even though my first select statement above does not have any alias name but the second one still have, why the result still shows 'No column name'?