SQL 2023 · Aggregation and window functions
Rank rows
Rank products by price, giving ties the same rank.
SELECT name, price, RANK() OVER (ORDER BY price DESC) AS price_rank FROM products;
Official SQL 2023 documentation
More aggregation and window functions commands
- Count rows
- Group and total
- Filter groups
- Number rows within groups
- Compute a running total
- Compare with the previous row
All aggregation and window functions commands · SQL 2023 cheatsheet