Using TOP with ROW_NUMBER

  • Comments posted to this topic are about the item Using TOP with ROW_NUMBER

  • I really should read these more closely. I may even get some right.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Well done!

  • Is this one is scoring properly?  The Explanation says that Query #2 won't run and Query #1 is the answer.  However, my choice of #1 was scored as incorrect and #2 was listed as the answer.

  • I think there is a typo in the answer as it describes query number 2 in the answer but mentions a WHERE clause which only exists in Query number 3.  It mentions Query number 1 and mentions it uses a CTE, which is used in Query number 2.

    The correct answer is query 2; the answer just incorrectly mentions query 2 as not running instead of query 3 as not running and that query 1 is the answer when query 2 is the answer.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • Sorry, typo in the explanation. Query #2 is the answer and it is scoring properly. I updated the explanation. Query#1 -- wrong results. Query #3 won't run.

Viewing 6 posts - 1 through 5 (of 5 total)

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