UNION, INTERSECT & EXCEPT · Question 8 · Medium

Table MondaySale: item Tea Samosa Tea Vada Table TuesdaySale: item Samosa Poha Which items does this query return?

SELECT item FROM MondaySale
EXCEPT
SELECT item FROM TuesdaySale
ORDER BY item;
  1. Tea; Tea; Vada
  2. Poha; Tea; Vada
  3. Vada
  4. Tea; Vada
Answer and explanation

Answer: D. Tea; Vada

Explanation: EXCEPT removes Samosa because it is also in TuesdaySale, and it returns distinct rows, so the two Tea rows become one. Poha is only in the second table, and EXCEPT never adds rows from the second query.

Previous: A query is written as SELECT emp_name FROM Staff UNION SELECT trainee_name… · Next: Table Employee: id | name 1 | Kavya 2 | Lokesh Table Intern: id | name |…

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