Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do I create a CAML query to display all items on the list order by ItemChildCount?

Somewhat like this:

 Select * 
 from table 
 order by itemChildCount descending 
share|improve this question

2 Answers 2

up vote 2 down vote accepted

I believe the OrderBy Element is what you're looking for:

SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='ItemChildCount' Ascending='FALSE' /></OrderBy>"; 

Adapted from the example here: SPQuery.ViewFields

Additionally, this is a useful CAML Query reference: Query Schema

share|improve this answer
Still have problem on the query. I created another question… – Carls Jr. Jun 28 '11 at 11:03

Tools like Strammit or U2U can help you build any CAML you desire.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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