> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for RANK function

# RANK OVER

Rank the current row within the requested window with gaps.

For more information on usage, please refer to [Window Functions](/reference-sql/functions-reference/window).

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
RANK() OVER ([PARTITION BY <partition_by>] ORDER BY <order_by> [ASC|DESC] )
```

## Parameters

| Parameter        | Description                                                                                        | Supported input types |
| :--------------- | :------------------------------------------------------------------------------------------------- | :-------------------- |
| `<partition_by>` | The expression used for the `PARTITION BY` clause.                                                 | Any                   |
| `<order_by>`     | The expression used in the `ORDER BY` clause. This parameter determines what value will be ranked. | Any                   |

## Return Type

`INTEGER`

## Example

In this example, players are ranked by their score within each game level. Players with equal scores receive the same rank, and the next rank is skipped.

<div className="query-window">
  ```
  SELECT
      nickname,
      level,
      current_score,
      RANK() OVER (PARTITION BY level ORDER BY current_score DESC) AS rank_in_game
  FROM
      (VALUES
          ('kennethpark', 9, 76),
          ('burchdenise', 9, 89),
          ('ymatthews', 9, 75),
          ('sabrina21', 9, 89)
      ) AS t(nickname, level, current_score)
  ORDER BY level, nickname;
  ```

  | nickname <span>text</span> | level <span>int</span> | current\_score <span>int</span> | rank\_in\_game <span>long</span> |
  | :------------------------- | :--------------------- | :------------------------------ | :------------------------------- |
  | burchdenise                | 9                      | 89                              | 1                                |
  | kennethpark                | 9                      | 76                              | 3                                |
  | sabrina21                  | 9                      | 89                              | 1                                |
  | ymatthews                  | 9                      | 75                              | 4                                |

  <p><span>Rows: 4</span><span>Execution time: 2.79ms</span></p>
</div>
