Query the attendceemprank table. The primary key is attendceemployeerank ID and it is a clustered index
Executing the following statement, it is found that the first sentence does not specify order by, and the result is different from the second sentence.
Looking at the execution plan, we can see that the first sentence uses the date index and the second sentence uses the primary key index
Let’s look at another set of SQL and query results:
The indexes used in the execution plan are also different:
Therefore, it is concluded that without specifying order by, SQL server will obtain data according to the actual query method of the execution plan, and the execution plan will use different indexes according to many factors in SQL (query columns, where conditions, order by, etc.), and the final results are likely to be different.