How to use Max to retrieve Max value from a field in the dataset?

  • Thread starter Thread starter Vanessa
  • Start date Start date
V

Vanessa

Hi
I would like to know how to Retrieve the Max Value from a field in the
DataSet? Is there any example?

Regards
Vanessa
 
Vanessa,
The simplest way is to add a column to the DataTable and set its expression
property to be Max(colname) where colname is the field you are interested
in. Every row in the datatable will then have a field with the same value.

Alternatively, you can create a second datatable with a relationship to the
first, and add the expression column to the second table. Then the
aggregation (Max) will be carried out on a grouping basis via the
relationship.

You can also use a DataView, set it to sort by the field in question, then
retrieve the first row from the sorted dataview.

Hope this helps,
Neil.
 
Back
Top