# ROW_NUMBER

A window function assigning consecutive numbers to rows within each window partition.

## What is **ROW_NUMBER** in a relational database?

**ROW_NUMBER** — A window function assigning consecutive numbers to rows within each window partition.

```sql
SELECT order_id,
       ROW_NUMBER() OVER (ORDER BY ordered_on) AS row_number
FROM purchase_order;
```

Level: Journeyman · [More Database terms at this level](https://www.ask-codey.com/glossary/subjects/database/journeyman)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/row-number
