How to add pagination to the following SQL
问题 I've got the following SQL and I want to know how to page it: I've got variables for @skip and @top so I can page through.. SELECT ID FROM ( SELECT COUNT(*) AS ID, -1 AS [Weight] FROM Employees i INNER JOIN #WeightedIDs w ON (i.ID = w.ID) WHERE (i.DepartmentID = 10 and i.ShiftID = 2) UNION ALL SELECT i.ID, w.[Weight] FROM Employees i INNER JOIN #WeightedIDs w ON (i.ID = w.ID) WHERE (i.DepartmentID = 10 and i.ShiftID = 2) ) x ORDER BY x.[Weight] ASC UPDATE: I've got the following but it doesn