UNION, INTERSECT & EXCEPT · Question 16 · Hard

UNION, INTERSECT & EXCEPT question 16

Table Cricket:
student
Aman
Bina
Chetan
Bina

Table Football:
student
Bina
Divya
Aman

The set operators below are applied from top to bottom. How many rows does this query return?

SELECT student FROM Cricket
UNION ALL
SELECT student FROM Football
UNION
SELECT student FROM Cricket;
  1. 7 rows
  2. 4 rows
  3. 11 rows
  4. 6 rows
Answer and explanation

Answer: B. 4 rows

Explanation: The UNION ALL first gives 7 rows. The final UNION then combines those with Cricket again and removes duplicates from the entire result, so only the distinct names Aman, Bina, Chetan and Divya remain.

Previous: Table Customer(cust_id, name) has 5 rows and table Supplier(supp_id, name) has… · Next: Table MayOrders: order_id | coupon 1 | SAVE10 2 | NULL 3 | NULL Table…

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