• And now, most importantly, here are the execution results I got running these queries on my 50 million row table.

    Hi Matt, I just found this discussion in the referrers to my blog.

    Both CROSS APPLY and ROW_NUMBER (or DENSE_RANK if you want ties) can be more efficient, depending on the cardinality of the field you're grouping (or partitioning) by.

    For high cardinality fields, analytic functions (ROW_NUMBER or DENSE_RANK) are more efficient due to the overhead of building a DISTINCT list of the values of this field.

    For low cardinality fields, CROSS APPLY is a more efficient solution, and that's what your test case shows.

    You may want to read another article in my blog, which compares both solutions performance-wise, depending on the cardinality of the field in question: SQL Server: Selecting records holding group-wise maximum (with ties)[/url]