Returning the Top X row for each group

  • ganotedp (11/23/2012)

    Why not DENSE_RANK instead of ROW_NUMBER?

    Hi ganotedp,

    The article does state

    If there were ties and we wanted each of them treated the same then we would use the DENSE_RANK function rather than ROW_NUMBER. In some systems if there is a tie, for example two runners finished in exactly the same time for first place, then there is no following position. That means no second place runner and we skip to third. We would then use the RANK function. In our example, however, we are going to ignore the possibility of ties.

    Clear Sky SQL
    My Blog[/url]

  • Great article - especially the CROSS APPLY option. I've come across the need for this several times (although sadly have been constrained by SQL 2000, which doesn't work with either option).

  • Thank you.

  • Nice article.

Viewing 4 posts - 31 through 33 (of 33 total)

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