Management & CommerceVery hardBusiness analyst · SQL test

sal(name, dept, s) has rows: dept X – A 90, B 90, C 80, D 70; dept Y – E 60, F 50, G 50, H 40. How many rows have DENSE_RANK() OVER (PARTITION BY dept ORDER BY s DESC) ≤ 2, and how many have RANK() … ≤ 2?

  1. A. DENSE_RANK: 5; RANK: 6
  2. B. DENSE_RANK: 6; RANK: 5
  3. C. DENSE_RANK: 4; RANK: 4
  4. D. DENSE_RANK: 6; RANK: 6

Correct answer: B. DENSE_RANK: 6; RANK: 5

In X, A and B tie at rank 1; DENSE_RANK gives C rank 2, but RANK gives C rank 3. In Y, E is 1 and F, G tie at 2 under both. So DENSE_RANK keeps A, B, C, E, F, G (6), while RANK keeps A, B, E, F, G (5).

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic