none
MAX value for a column? RRS feed

  • Question

  • Is there a way to query a datatable for the MAX value of column?  Can the Select() method be used in this manner?

    -Thx
    Wednesday, June 13, 2007 4:38 PM

Answers

  • Hi,

    You can use sql such as
    select max(Price) as MaxPrice from Products
    in combination with the ExecuteScalar method of the Command objects

    If all the data is in a dataset, you can use the Compute function of the DataTable object:
    http://msdn2.microsoft.com/en-us/library/system.data.datatable.compute.aspx

    Regards
    Wednesday, June 13, 2007 7:26 PM