DENSE_RANK

Description of dense_rank_aggregate.eps follows

Purpose

DENSE_RANK() is a special function in SQL that assigns ranks to rows within a specific result set portion. Unlike ROW_NUMBER(), DENSE_RANK() doesn’t leave any gaps in the ranking values. Here’s a straightforward breakdown:

What it does:

  • Assigns ranks to rows within partitions.
  • Avoids gaps in rank values for tied rows.
  • Resets rank when the partition changes.

BASIC SYNTAX

DENSE_RANK() OVER (
PARTITION BY partition_column_1, …
ORDER BY order_column_1, …
)

EXAMPLE 1: RANKING PRODUCTS

EXAMPLE 2: Ranking employees by salary within department:

https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/DENSE_RANK.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top