CS FundamentalsModerateGATE CS · SQL

Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). What does this query return?

Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). What does this query return?
SELECT pid FROM Product
WHERE price IS NOT NULL
ORDER BY price DESC, pid
LIMIT 2 OFFSET 1;
  1. A. 2, 3
  2. B. 2, 1
  3. C. 3, 1
  4. D. 4, 2

Correct answer: A. 2, 3

Sorted by price desc then pid: 4 (30), 2 (20), 3 (20), 1 (10), 6 (5). Skip one row and take two: 2, 3.

More DBMS and SQL questions

Exams that ask this topic