UNION, INTERSECT & EXCEPT · Question 12 · Medium

UNION, INTERSECT & EXCEPT question 12

Table Cricket:
student
Aman
Bina
Chetan
Bina

Table Football:
student
Bina
Divya
Aman

A label column is added to show where each row came from. How many rows does this query return?

SELECT student, 'C' FROM Cricket
UNION
SELECT student, 'F' FROM Football;
  1. 6 rows
  2. 4 rows
  3. 7 rows
  4. 5 rows
Answer and explanation

Answer: A. 6 rows

Explanation: With the label, a cricket row such as (Bina, C) is no longer equal to the football row (Bina, F), so UNION cannot merge them. Only the repeated (Bina, C) inside Cricket is removed: 3 distinct cricket rows + 3 football rows = 6.

Previous: Table Store: city | product Pune | Pen Pune | Ink Table Depot: city | product… · Next: Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…

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