Hi Guys,
Is there any way by which I can get the max value from a particular column of a datatable. Please let me know.
Regards,
Samir.
Printable View
Hi Guys,
Is there any way by which I can get the max value from a particular column of a datatable. Please let me know.
Regards,
Samir.
Are you talking about by SQL from a database or in an existing DataTable? If you mean froma database then it would just be:You would assign that to the CommandText of the appropriate type of command object and call ExecuteScalar. If you mean from an existing DataTable then you could create a DataView, or use the DefaultView, and set the Sort property to:Code:SELECT MAX(ColumnName) FROM TableName
and then get the value from that column of the first row in the view.Code:ColumnName DESC