RANK() returns consecutive integers

  • Koen (da-zero) (1/6/2011)


    toddasd (1/6/2011)


    Is it considered cheating that I went to the BOL before answering the question and read "If two or more rows tie for a rank, each tied rows receives the same rank."?

    I don't consider doing research and learning from it cheating.

    I'm not going to memorize every feature, trace flag, syntax, dmv of SQL Server. If I need something, I'll look it up 🙂

    I agree! It's impossible to remember details of every command of every language.

    🙂

  • toddasd (1/6/2011)


    Is it considered cheating that I went to the BOL before answering the question and read "If two or more rows tie for a rank, each tied rows receives the same rank."?

    "Cheating" implies that this is a test - which it isn't. QotD is designed to do just this - get you looking into areas of SQL that you might not have been aware of. If you researched something, and learned from it, then mission accomplished.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • I knew that Rank() skips the number if there is a tie but thought it's still consecutive number in a sense next available int number.

  • The RANK Function is a pretty interesting topic and a great pick. Below is an great example too using the AdventureWorks200R2 database.

    URL: http://msdn.microsoft.com/en-us/library/ms189798.aspx

    Thank you for the question.

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply