我正在使用@skip和@take參數進行分頁。分頁後我需要總行數。我怎樣才能做到這一點,作爲表現的最佳方式?如何在應用分頁後獲取總行數
CREATE PROCEDURE Search
@Take Int = 10
@Skip Int = 0
@TotalRows Int Out
AS
BEGIN
Select
RowNo, FirstName, LastName
From
(
Select Row_Number()Over(Order By Id) As [RowNo],
FirstName,
LastName
From Users
) tblTemp
Where RowNo > @Skip And RowNo <= @Take + @Skip
Set @TotalRows = ??? -- I need the number of total rows after applying paging. How can I do this?
END
請標記您的DBMS,例如MySQL,SQL-Server,Oracle –
@SteveLovell,謝謝。我編輯了標籤。 –