Similar questions 2 more →
SQL & Queries

Answer & solution
Answer: A (no official key was published)
1. Approach. NOT EXISTS rejects the presence of a counterexample to “greater than everyone.” SQL ANY is existential: satisfying one comparison suffices. DISTINCT does not change that quantifier.
2. Derivation and interpretation. For each e, Q1 excludes e whenever any department-5 employee has salary >= e.salary. Thus it keeps exactly salaries strictly greater than the department maximum. Q2 uses > ANY, which means greater than at least one returned salary, not every salary. For department salaries 10 and 20, a salary 15 passes Q2 but not Q1. Hence A under the usual non-NULL salary interpretation. Strict SQL NULL semantics require qualification: NULL comparisons are UNKNOWN, so Q1 can admit NULL salaries or ignore unknown department salaries; no NOT NULL constraint is printed.