Create CAML SPQuery to order by ItemChildCount in descending order
-
16-10-2019 - |
Question
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
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange