SQL Window Functions Series: RANK() and DENSE_RANK()


Welcome to the fascinating world of SQL Window functions! As we journey through the intricate labyrinths of databases and large datasets, having the right tools to aggregate, compute, and analyze data becomes indispensable. Today, we’ll explore two of these tools in detail: RANK() and DENSE_RANK(). But before we dive into these functions, let’s understand what window functions are and why we should use them.

What are Window Functions?

SQL window functions, also known as OLAP (Online Analytical Processing) functions, are a subset of SQL functions that operate over a set (or « window ») of rows related to the current row within