SQL Query: How can I get data of row with number 1000 direclty?

前端 未结 3 834
耶瑟儿~
耶瑟儿~ 2021-01-01 09:31

If I have a SQL Table called Persons that contain about 30000 rows and I want to make a SQL query that retrieve the data of row number 1000 ... I got it by non

3条回答
  •  一向
    一向 (楼主)
    2021-01-01 09:45

    In SQL Server 2005+ you can use the following:

    WITH MyCte AS 
    (
        SELECT
            [CategoryId]
            ,[CategoryName]
            ,[CategoryDescription]
            ,ROW_NUMBER() OVER (ORDER BY CategoryId ASC) AS RowNum
        FROM
            [Carmack].[dbo].[job_Categories]
    )
    SELECT *
    FROM    MyCte
    WHERE   RowNum = 3
    

提交回复
热议问题