Simon Simon - 2 years ago 98
SQL Question

Search Distinct values in DataTable

I have a datatable that has a few thousand rows, there are three columns and I want to search the one specific column in the datatable to find the Distinct values. I have tried this:

DataRow[] dr = datatable.Select("SELECT DISTINCT Amount ");

Amount is the column name that I am trying to group the values by.

The error I get is:
Syntax error: Missing operand after 'DISTINCT' operator


Answer Source
  DataView view = new DataView(datatable);
  DataTable distinctAmount = view.ToTable(true, "Amount", "xxx","xxxx"...);

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download