进行以下查询。
;WITH CTE AS(
SELECT
*,
RowNumber = ROW_NUMBER() OVER(PARTITION BY Field1, Field2 ORDER BY Field3 DESC)
FROM Table)
SELECT *
FROM CTE
WHERE RowNumber <= 3
ORDER BY Field1,RowNumber DESC
和
SELECT
*
FROM
(
SELECT
*,
RowNumber = ROW_NUMBER() OVER(PARTITION BY Field1, Field2 ORDER BY Field3 DESC)
FROM Table
)AS X
WHERE
X.RowNumber <= 3
ORDER BY
Field1,
RowNumber DESC
我知道cte的一些优点,包括压缩代码,精细子查询的可读性和使用递归等的技术等。
话虽如此,关于编译/优化这两个查询是否相同?