• cengland0 (1/6/2011)


    When the question asked will it always return consecutive integers, I knew right away that it was false because none of them will always return consecutive integers if there is only one row.

    Meh, I could just as well say that everything is consecutive in a single-row rowset.

    According to http://www.thefreedictionary.com/consecutive, "consecutive" means (a.o.) "Following one after another without interruption" - and in a single row row-set, there can never be any interruption.

    The reason that RANK does not return consecutive values is how ties are handled - for instance, if the RANK is based on the scores {9.6, 8.4, 9.6}, the results would be

    Score Rank

    9.6 1

    9.6 1

    8.4 3

    Because two rows get the rank 1, the value 2 is skipped. That makes the values non-consecutive.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/