Assigns a rank to each row. Rows with equal values receive the same rank, and there is a gap after ties.
INT64Diperbarui: 13 Jun 2026RANK() OVER ([PARTITION BY partition_expression] ORDER BY sort_expression)Determines the ranking order
Divides data into groups (optional)
1 SELECT 2 name, 3 score, 4 RANK() OVER (ORDER BY score DESC) as rank 5 FROM `project.dataset.contestants`;
Rank contestants by score, with a gap after tied values.
| name | score | rank |
|---|---|---|
| Alice | 100 | 1 |
| Bob | 100 | 1 |
| Charlie | 90 | 3 |
| David | 80 | 4 |
1 SELECT 2 salesperson, 3 region, 4 total_sales, 5 RANK() OVER (PARTITION BY region ORDER BY total_sales DESC) as region_rank 6 FROM `project.dataset.sales_summary`;
Rank salespeople by total sales within each region.
Sudah paham RANK? Latih langsung di browser
Latihan interaktif, langsung di browser.