我正在进行 que问,将一栏中的最大数值退回该方案。
斜线一行。
select MAX([Line No]) from table
I am using sql server 2008.
该表有三行:线 无数值50、90、100
the max value i expect to be returned is 100, but im getting 90..why?
EDIT:
string LineNo = "0";
//LineNo
string SQLlineno = "select MAX(CAST([Line No] As Int)) from Saved_Order_Import where [order no] = "
+ ordernumber + " ";
SqlCommand myCommandlineno = new SqlCommand(SQLlineno, myConnection);
SqlDataReader readerline;
try
{
readerline = myCommandlineno.ExecuteReader();
if (readerline.HasRows)
{
while (readerline.Read())
{
try
{
if (readerline.GetString(0) != null)
{
LineNo = (readerline.GetString(0) + 10).ToString();
}
}
catch (Exception ex) { return "{"error":"line : " + ex.ToString() + ""}"; }
}
}
readerline.Close();
}
catch (Exception ex)
{
// return "{"error":"Other One11" + ex.ToString() + ""}";
}