count(1)不要和查询数据混用 非常耗时
例子:
SELECT w.[PKID],
COUNT(1) OVER() AS TotalCount
FROM w WITH(NOLOCK)
INNER JOIN s WITH(NOLOCK)
ON s.PKID= w.SID
INNER JOIN s2 WITH (NOLOCK)
ON s2.PKID= w.SID2
INNER JOIN w2 AS WTLWITH(NOLOCK)
ON W2.WID=w.PKID
ORDER BY w.PKID
OFFSET 0 ROW FETCH NEXT 15 ROW ONLY