本文介绍了如何获取数据表中列的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含一些行和列的数据表。
I have a datatable which contains some rows and clumns.
Product To (m) A 12.6 B C 30.1 D 40 E现在我想检索To(m)列的最大值。 To(m)也有一些NULL值。 例如 最大值(m)= 40 能为您提供合适的解决方案吗?
Now I want to retrieve the maximum value Of To (m) column. To (m) has some NULL values also. For example Maximum To (m) =40 Can you please provide me a suitable solution for this?
推荐答案试试这个,它将绘制出那些包含最大值的行,我们只选择第一个并在文本框中显示它。 Null在这里不是一个问题。我假设[To(m)]的列索引是1. Try this, it will draw out those rows that hold the max value, and we just pick the first one and display it in a textbox. Null is not a concern here. I assume the column index of [To (m)] is 1. DataRow[] dr = datatable.Select("[To (m)] = MAX([To (m)])"); textBox1.Text = dr[0][1].ToString();
访问这里...... social.msdn.microsoft/Forums/en-US/3dc001ae-031c-4ef1-a911-291953af4b9a/find-maximum-value-from-the-datatable?forum=adodotnetdataproviders [ ^ ] visit here... social.msdn.microsoft/Forums/en-US/3dc001ae-031c-4ef1-a911-291953af4b9a/find-maximum-value-from-the-datatable?forum=adodotnetdataproviders[^]
使用选择(同样过滤器) DataView RowFilter语法 [ ^ ] 在DataTable.Select()中使用Max,Min和Sum聚合函数[ ^ ] Use Select (also Filter) DataView RowFilter Syntax[^] Using Max, Min and Sum aggreate functions in DataTable.Select()[^]
更多推荐
如何获取数据表中列的最大值
发布评论