如何从数据库中的特定列获取最大值 [英] how to get maximum value from a specific column in database
本文介绍了如何从数据库中的特定列获取最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为myvalues的表列,一个asp.net网页包含一个按钮.我想要当用户单击按钮时,它从该myvalues列中取最高值并显示在页面上.
i have a table column named myvalues, an asp.net webpage contains one button. i want when user click on button it takes the highest value from that myvalues column and show it on the page. how is it possible.?
推荐答案
您需要一个类似于以下内容的SQL命令:
You need an SQL Command similar to:
SELECT MAX(myColumn) FROM myTable
SqlCommand cmd = new SqlCommand("select max(myColumn) as myColumnfrom myTable", con);
con.Open();
string a =Convert.ToString( cmd.ExecuteScalar());
Response.Write(a);
con.Close();
使用它
use it
这篇关于如何从数据库中的特定列获取最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文