Management & CommerceVery hardBusiness analyst · KPO · MBA placement pattern

Table emp_sales(rep, region, amount) has 8 rows: (Asha, North, 500), (Ravi, North, 700), (Meena, North, 700), (Kiran, North, 300), (Dev, South, 400), (Sara, South, 900), (John, South, 400), (Neha, South, 200). How many rows does this query return? SELECT rep FROM (SELECT rep, RANK() OVER (PARTITION BY region ORDER BY amount DESC) AS rk FROM emp_sales) t WHERE rk <= 2;

  1. A. 4
  2. B. 6
  3. C. 3
  4. D. 5

Correct answer: D. 5

North: Ravi and Meena tie at rank 1; Asha is rank 3, so 2 rows. South: Sara rank 1; Dev and John tie at 400 → both rank 2, so 3 rows. Total 5. ROW_NUMBER would return exactly 4; DENSE_RANK would also keep Asha and return 6.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic