> ## 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":"github-light","dark":"github-dark"}}
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 below, players are ranked based on their test scores for their game level.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
	nickname,
	level,
	current_score,
	RANK() OVER (PARTITION BY level ORDER BY current_score DESC ) AS rank_in_game
FROM
	players;
```

**Returns**:

| first\_name | grade\_level | test\_score | rank\_in\_class |
| :---------- | :----------- | :---------- | :-------------- |
| kennethpark | 9            | 76          | 6               |
| burchdenise | 12           | 89          | 5               |
| ymatthews   | 11           | 75          | 3               |
| sabrina21   | 10           | 78          | 3               |
