# Rank

Create a ranking of values in a column.

## Parameters

| Name               | Type            | Description                                                                                                                                                                                                   | Is Optional |
| ------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| rank\_columns      | column\_list    | The column or expression to order (rank) by                                                                                                                                                                   |             |
| partition\_by      | column\_list    | The column or expression to partition the window by. Accepts .                                                                                                                                                | True        |
| order              | sort\_direction | Instruction on how to order the rank\_column. Accepts , but defaults to ASC. ASC = Ascending DESC = Descending                                                                                                | True        |
| rank\_type         | value           | Type of ranking \[ \| dense \| percent \| unique ]. Accepts . = ANSI SQL rank function dense = ANSI SQL dense\_rank function percent = ANSI SQL percent\_rank function unique = ANSI SQL row\_number function | True        |
| qualify\_filter    | value           | A filter to apply to the ranked column. Accepts .                                                                                                                                                             | True        |
| alias              | string          | Name of the output column containing rankings                                                                                                                                                                 | True        |
| overwrite\_columns | boolean         | Optional: if true, the columns passed in 'rank\_columns' will be dropped from the output                                                                                                                      | True        |

## Example

```python
#Return the 5 highest temperatures per date:
ds = rasgo.get.dataset(dataset_id)

ds2 = ds.rank(rank_columns=['DS_DAILY_HIGH_TEMP'],
      partition_by=['DATE'],
      ORDER='DESC',
      RANK_TYPE='unique',
      QUALIFY_FILTER='>=5'
})

ds2.preview()

```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/rank/rank.sql>" %}
