how to select first N rows from a table in T-SQL?

前端 未结 7 896
耶瑟儿~
耶瑟儿~ 2020-12-10 10:54

Is there any way to select, for example, first 10 rows of a table in T-SQL (working MSSQL)?
I think I saw something in Oracle defined as rownum meta variable, used in a

7条回答
  •  佛祖请我去吃肉
    2020-12-10 11:33

    SELECT TOP 10 *
    FROM Users
    

    Note that if you don't specify an ORDER BY clause then any 10 rows could be returned, because "first 10 rows" doesn't really mean anything until you tell the database what ordering to use.

提交回复
热议问题