UNION, INTERSECT & EXCEPT · Question 17 · Hard
UNION, INTERSECT & EXCEPT question 17
Table MayOrders:
order_id | coupon
1 | SAVE10
2 | NULL
3 | NULL
Table JuneOrders:
order_id | coupon
4 | NULL
5 | FEST20
Orders placed without a coupon have NULL in the coupon column. What does this query return?
SELECT COUNT(*)
FROM (SELECT coupon FROM MayOrders
INTERSECT
SELECT coupon FROM JuneOrders) t;
- 1
- 0
- 2
- 3
Answer and explanation
Answer: A. 1
Explanation: Set operators treat two NULLs as the same value, unlike the = operator in a WHERE clause. NULL is present on both sides, so INTERSECT returns a single NULL row; SAVE10 and FEST20 each appear on one side only.
Previous: Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina… · 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
- 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 Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
- 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