Take this simple SPQuery for example:

SPQuery query = new SPQuery();
query.Query = "<Where><IsNotNull><FieldRef Name='Modified' /></IsNotNull></Where>";
query.RowLimit = 10;

Notice that "OrderBy" is not defined in the query.

In this case, how are the results of the SPQuery sorted before the top 10 records are selected to be returned?

Will the above query return 10 random items since no "OrderBy" is defined?

EDIT: The reason for this question was a mistake I made where I performed sorting on the query results instead of using "OrderBy" in the query. After setting RowLimit, I could not get the most recently modified items from a list.

The lesson here is to use "OrderBy" instead of sorting the results returned by the query when RowLimit is set.

1 Answer 1


If you don't specify the Order by in "SPQuery" as mention above the data return will Order by ID/Id of item of the list in Ascending order.

For Quick result you can check with rest api on browser as below:

  • I've also done some testing on my own, and you are correct. Thanks!
    – Tony
    Sep 21, 2017 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.