我需要在Sql Server的前10条记录中显示最多9条记录。
以下是我选择前10条记录的查询。
select top(10) * from Employee
答案 0 :(得分:2)
;WITH MyCTE AS
(
SELECT *,
ROW_NUMBER() OVER (ORDER BY EmployeeID) AS RowNum
FROM Employee
)
SELECT * FROM MyCTE WHERE RowNum = 9