如何获取数据表中列的最大值

编程入门 行业动态 更新时间:2024-10-10 05:16:46
本文介绍了如何获取数据表中列的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个包含一些行和列的数据表。

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()[^]

更多推荐

如何获取数据表中列的最大值

本文发布于:2023-11-05 03:01:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559728.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最大值   数据表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!