PostgreSQL · Function
row_number
row_number gives each row a sequential number within its window partition, starting at 1. Use OVER with ORDER BY to define the numbering order.
Last updated
Syntax
row_number() OVER ( [ PARTITION BY partition_expression ] [ ORDER BY sort_expression [ ASC | DESC ] ] )In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
rankdense_ranklagleadOVER clausePARTITION BYWINDOW clause