Friday, December 14, 2007

How to get the Maximum value in the same column?

How to get the Maximum value in the same column?


You can also get the maximum value in the same column of the table.


The ASP codes are written and described as below:

<%

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

Set rs = Server.CreateObject("Adodb.Recordset")

strSQL ="SELECT Max(Price) As MinPrice FROM Stock;" 'Select a single record that is highest price in the stock.

rs.Open strSQL,conn,1,3

If Not rs.EOF Then

Response.Write("The highest price in the Stock is " & rs.fields("MinPrice") & "
")

End If

rs.Close

Set rs = Nothing

%>


No comments: