Back to Developer Roadmap

rank

src/data/roadmaps/sql/content/[email protected]

4.0875 B
Original Source

rank

The RANK function in SQL is a window function that assigns a rank to each row within a partition of a result set, based on the order specified by the ORDER BY clause. Unlike the ROW_NUMBER function, RANK allows for the possibility of ties—rows with equal values in the ordering column(s) receive the same rank, and the next rank is skipped accordingly. For example, if two rows share the same rank of 1, the next rank will be 3. This function is useful for scenarios where you need to identify relative positions within groups, such as ranking employees by salary within each department.

Visit the following resources to learn more: