今天看书讲T-SQL,看到了UNBOUNDED PRECEDING,就想比对下ROW_NUMBER()的运行速度。 sql及相关的结果如下,数据库中的数据有5W+。 ROW_NUMBER(): SET STATISTICS TIME ON SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) rn,Id FROM dbo.T_MyCourse 运行结果 UNBOUNDED PRECEDING SET STATISTICS TIME ON SELECT SUM(1) OVER(ORDER BY Id DESC ROWS BETWEEN UNBOU