From the course: Complete Guide to SQL for Data Engineering: from Beginner to Advanced

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Exploring the ROW_NUMBER() function

Exploring the ROW_NUMBER() function

- [Narrator] Imagine you are at airport eagerly waiting for your flight. In the crowd, you noticed a display board indicating the boarding order for passengers. Each person is assigned a unique number, determining when they get to board the plane. In the world of databases, the SQL function row number serves a similar purpose, providing a distinctive identifier to each row within your result set. The row number function in PostgreSQL is a window function that assigns a unique number to each row in the result set according to the specified order. Unlike the rank and the dense rank function, row number function does not assign the same value for duplicate rows. Remember, row number is not a ranking function. Even if two rows are identical based on the ordering, each row will get a distinct row number starting from 1 within each partition. Let's take a one real-world use case. Imagine you want to analyze the sequence of…

Contents