UNION, INTERSECT & EXCEPT · Question 7 · Easy

A query is written as SELECT emp_name FROM Staff UNION SELECT trainee_name FROM Trainee. What is the column of the combined result called?

  1. trainee_name, taken from the last SELECT
  2. emp_name, taken from the first SELECT
  3. emp_name_trainee_name, joining both names
  4. It has no name until an alias is given to the whole UNION
Answer and explanation

Answer: B. emp_name, taken from the first SELECT

Explanation: The column names of a UNION, INTERSECT or EXCEPT result come from the first SELECT. Names or aliases in the later SELECTs are ignored.

Previous: Two queries are known to have no rows in common, and neither has duplicates… · Next: Table MondaySale: item Tea Samosa Tea Vada Table TuesdaySale: item Samosa Poha…

Practise union, intersect & except

Try a fresh set of union, intersect & except questions with an explanation after every answer, free and without signing up: UNION, INTERSECT & EXCEPT practice. Or sit a full placement mock test.

More union, intersect & except questions

More sql practice

Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge