|
一、從一個熟悉的示例說起
我們熟知的數據庫分頁查詢,以這一篇介紹過的為例吧。分頁查詢Person表中的人,可以這么寫SQL語句:WITH Record AS (
SELECT
Row_Number() OVER (ORDER BY Id DESC) AS RecordNumber,
Id,
FirstName,
LastName,
Height,
Weight
FROM
Person (NOLOCK)
)
SELECT
RecordNumber,
(SELECT COUNT(0) FROM Record) AS TotalCount,
Id,
FirstName,
LastName,
Height,
Weight
FROM Record
WHERE RecordNumber BETWEEN 1 AND 10
it知識庫:總結SQL Server窗口函數的簡單使用,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。