Window Functions · SQL SQL
Which ranking window function assigns the same rank to identical values with no gaps in ranking sequence, meaning if two rows share rank 1, the next…
Practice question from Window Functions (SQL SQL), with the correct answer and a step-by-step solution.
medium · MCQ · Q-06BBB0
Which ranking window function assigns the same rank to identical values with no gaps in ranking sequence, meaning if two rows share rank 1, the next rank is 2?
- A.ROW_NUMBER()
- B.RANK()
- C.DENSE_RANK()Correct answer
- D.NTILE()
Solution
DENSE_RANK() assigns consecutive ranks to rows with duplicate values without leaving gaps in the ranking sequence. In contrast, RANK() leaves gaps (e.g., 1, 1, 3), and ROW_NUMBER() assigns unique sequential numbers.
More from Window Functions
- What is the primary difference between using a standard aggregate function with GROUP BY and using a window function in SQL?
- Consider the following query: SELECT employeeid, departmentid, salary, ROWNUMBER() OVER (PARTITION BY departmentid ORDER BY salary DESC) as…
- What is the default frame specification in a window function when an ORDER BY clause is provided, but no explicit ROWS or RANGE frame is sp…
- Explain the difference between the ROWS and RANGE framing clauses in SQL window functions.
Practise more SQL
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed