SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using ClientObjectModel (C#) to retreive data from a custom list, which is structured like this:


What i need is some kind of "select distinct" which retreives only the categories, without duplicates:

cat1; cat2; cat3;

Im not able to find a way with CAML, and iterating through all items is not an option (the list contains 6000 items, to load each of them is very slow). Is there any other way I dont know?

share|improve this question
up vote 2 down vote accepted

Literally CAML query even in SharePoint 2013 doesn't have distinct function you can use, however I find this code that can help you,

 protected void btn_binddropdown_Click(object sender, EventArgs e)
                SPList oList = SPContext.Current.Web.Lists["CAMLTEST"];
                SPQuery query = new SPQuery();
                query.Query = "<OrderBy><FieldRef Name='Name' /></OrderBy>";
                DataTable dtcamltest = oList.GetItems(query).GetDataTable();
                DataView dtview = new DataView(dtcamltest);
                DataTable dtdistinct = dtview.ToTable(true, "Name");
                ddl_names.DataSource = dtdistinct; 
                ddl_names.DataTextField = "Name";
                ddl_names.DataValueField = "Name";

            catch (Exception exe)
                Response.Write("Exception at btn_binddropdown_Click :" + exe);

enter image description here


If nothing works then you still have choice of Custom web services or use jQuery or JS to select distinct list items,

Possible to get distinct values from GetListItems?

How to retrieve distinct values with JavaScript Client Object Model

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.