Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

row_number() vs rank() and dense_rank() analytical functions

Colin'tHartMay 5 2006 — edited May 5 2006
Hi,

What's the difference between the row_number(), rank() and dense_rank() analytical functions?

The way I understand it (for example dataset: A, B, B, C, C, D, E, F)
* row_number() always yields ascending numbers for each row (1, 2, 3, 4, 5, 6, 7, 8)
* rank() numbers equivalent rows with the same number and then skips to the next number (1, 2, 2, 4, 4, 6, 7, 8)
* dense_rank() is like rank but doesn't skip (1, 2, 2, 3, 3, 4, 5, 6)

And there's no difference between the three if you never have 'duplicate rows'.

Am I correct here?

Thanks,

Colin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 2 2006
Added on May 5 2006
1 comment
591 views