SQL Interview: 92 SELECT without specified order
This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Development Level: Intro
Question:
You issue the following query against the dbo.Customers table:
SELECT * FROM dbo.Customers;
The table has a clustered index on the CustomerID column.
When you have not specified an ORDER BY clause, which order will the rows be returned in?
A) No predictable order B) CustomerID order C) Order that rows were first inserted
Answer:
When you do not specify an ORDER BY clause, there is no deterministic order that rows will be returned in. So, the answer is A.
Often in testing, developers see rows apparently being returned in particular orders, like the clustering key order, but this is not guaranteed. If you want rows in a particular order, you must specify an ORDER BY clause.
2025-11-29