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.
Thanks, I've update the post. Why did I find RANK() first when this ROW_NUMBER() is exists 🤦♂️
RANK()
ROW_NUMBER()
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.
Thanks, I've update the post. Why did I find
RANK()
first when thisROW_NUMBER()
is exists 🤦♂️