UNION, INTERSECT & EXCEPT · Question 5 · Easy

Which condition must two SELECT statements satisfy before they can be combined with UNION?

  1. They must return the same number of columns, with compatible data types in matching positions
  2. They must read from the same table
  3. Their columns must have exactly the same names
  4. They must return the same number of rows
Answer and explanation

Answer: A. They must return the same number of columns, with compatible data types in matching positions

Explanation: Set operators line the two results up column by column, so the column count must match and each pair of columns must have compatible types. Table names, column names and row counts can differ.

Previous: Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina… · Next: Two queries are known to have no rows in common, and neither has duplicates…

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