Last answered:

01 Jul 2022

Posted on:

30 Jun 2022

1

Why using the first SELECT in the solution

I ran the following query and both the solution's and this query seem to result in the same set, could anyone explain why is there the first SELECT * FROM in the solution?

SELECT

e.emp_no,

e.first_name,

e.last_name,

NULL AS dept_no,

NULL AS from_date

FROM

employees e

WHERE

last_name = 'Denis' UNION SELECT

NULL AS emp_no,

NULL AS first_name,

NULL AS last_name,

dm.dept_no,

dm.from_date

FROM

dept_manager dm

1 answers ( 0 marked as helpful)
Instructor
Posted on:

01 Jul 2022

0

Hi Saeed!
Thanks for reaching out.

It is used because we can use an alias and then we can use this order of the result set. Your solution is also correct.

Hope this helps.
Best,
Tsvetelin

Submit an answer