Management & CommerceVery hardBusiness analyst · SQL test

Table e(name, s) has salaries A 90, B 90, C 80, D 70. What do these return? P: SELECT DISTINCT s FROM e ORDER BY s DESC LIMIT 1 OFFSET 1; Q: SELECT s FROM e ORDER BY s DESC LIMIT 1 OFFSET 1.

  1. A. P = 90, Q = 80
  2. B. P = 80, Q = 80
  3. C. P = 80, Q = 90
  4. D. P = 70, Q = 80

Correct answer: C. P = 80, Q = 90

Without DISTINCT the sorted list is 90, 90, 80, 70, so skipping one row gives 90 again. With DISTINCT it is 90, 80, 70, and skipping one gives 80 – the true second-highest salary.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic