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;
- 7 rows
- 4 rows
- 11 rows
- 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
- Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
- Table SectionA: name | marks Gita | 70 Hari | 90 Table SectionB: name | marks…
- Table Customer(cust_id, name) has 5 rows and table Supplier(supp_id, name) has…
- Table MayOrders: order_id | coupon 1 | SAVE10 2 | NULL 3 | NULL Table…
- Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
- Tables A and B each have a column id that is declared NOT NULL. A.id can…
- Table Cricket: student Aman Bina Chetan Bina The same table is used on both…
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