Bird
0
0

What result does this query produce?

medium📝 query result Q5 of 15
PostgreSQL - Window Functions in PostgreSQL
What result does this query produce?
SELECT employee_id, salary, DENSE_RANK() OVER (ORDER BY salary ASC) AS rank FROM employees;
AAssigns ranks to employees based on ascending salary, with no gaps in ranking
BAssigns ranks with gaps where salaries are tied
CCalculates cumulative salary totals per employee
DReturns employees ordered by salary without ranking
Step-by-Step Solution
Solution:
  1. Step 1: Understand DENSE_RANK()

    DENSE_RANK() assigns ranks without gaps for tied values.
  2. Step 2: Analyze ORDER BY salary ASC

    Ranks are assigned starting from lowest salary upwards.
  3. Final Answer:

    Assigns ranks to employees based on ascending salary, with no gaps in ranking -> Option A
  4. Quick Check:

    DENSE_RANK() gives consecutive ranks even if ties exist [OK]
Quick Trick: DENSE_RANK() avoids gaps in ranking [OK]
Common Mistakes:
  • Confusing DENSE_RANK() with RANK()
  • Assuming cumulative sums are calculated
  • Thinking query orders without ranking

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes