如何在列中找到最大值 [英] how find max value in column
本文介绍了如何在列中找到最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取表中的最大值.
我需要查找,在termtest表中具有最大总数的人.即时通讯使用vb.net和sql server.请帮助我.谢谢
How get maximum value in the table.
i need find, who have max total in the termtest table. im using vb.net and sql server. pls help me. thanks
推荐答案
在sql server中:
In sql server:
select max(column_name) from table_name
例如:
Ex:
select max(total) from termtest
如果要从DataTable
查找最大值,则可以使用以下代码,其中termtest
是DataTable,是数据类型为 Decimal
的列
In case if you want to find the maximum values from theDataTable
, then the following code can be used, in whichtermtest
is DataTable,total
is the Column of data typeDecimal
Dim RowsInDescending As DataRow() = termtest.select("", "total DESC", System.Data.DataViewRowState.CurrentRows)
Dim MaxTotal As Decimal
If RowsInDescending.Length > 0 Then
MaxTotal = CDec(RowsInDescending(0).Item("total"))
End If
这篇关于如何在列中找到最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文