How to select distinct from SPQuery CAML

A handy way to select distinct records from SPListItemCollection set queried from CAML query. This is very useful when we want to select a number of unique records from a data table.

DataTable dtt = myWeb.Lists["LISTNAME"].GetItems(spQuery).GetDataTable();
DataView dtv = new DataView(dtt);
dtt = dtv.ToTable(true, "COLUMNNAME");
Categories: Sharepoint 2007
Tags: