DEV Community

Discussion on: Additional Column for Incremental Numbering in SQL

Collapse
 
geraldew profile image
geraldew

I suggest you read the very tutorial page that you gave a link to - as it clearly explains that the Rank function does not guarantee consecutive numbers.

For that you're better off using the Row_Number function. See SQL Window Functions - SQL ROW_NUMBER

p.s. yes there's also the DENSE_RANK() function, but it's not as reliably present across dialects.

Collapse
 
dendihandian profile image
Dendi Handian • Edited

Thanks, I've update the post. Why did I find RANK() first when this ROW_NUMBER() is exists 🤦‍♂️