- ASP - Database Table Display
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


SQL: Sum,Average,Max,Min,Count,Detail
There are a great many statistics that you can perform on your data with simple sql. Sum, Average, Max, Min, and Count can be derived nearly as easy as showing the complete detail of your data.  The following example utilizes our db (trade date, closing price and daily volume) of  EPOS ( stock trading performance.  Each of the statistics are available in a dropdown menu and the sql that is used on the daily volume is displayed.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

' Check to see if the user inputted a value for the stat to be shown
' If it's null skip the query to the db and just show the imput form
if u_title<>"" then
select case u_title
' All of the sql available from the dropdown menu is listed here
case "Average"
sql = "select avg(volume) as vol from epos"
case "Min"
sql = "select min(volume) as vol from epos;"
case "Max"
sql = "select max(volume) as vol from epos;"
case "Sum"
sql = "select sum(volume) as vol from epos;"
case "Count"
sql = "select count(volume) as vol from epos;"
case "Detail"
sql = "select volume as vol from epos;"
end select

cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, cn

<body bgcolor="#FFFFFF">
<title><%= sql %></title> 
<table border="0" align="center" width="100%">
<tr><td align="center">
<p><%= sql %></p> 
<table border="5" cellpadding="3" cellspacing="3" align="center">
Volume<br>(<%= u_title %>)
do while not rs.eof

<%= formatnumber(rs("vol"),0) %>

end if

<form action="<%= request.servervariables("script_name") %>"
if u_title = "" then %>

<table align="center"><tr><td>Please make a selection<br>
<% end if %>

<select name="u_title" size="1">
<% if u_title <> "" then %>
<option selected value="<%= u_title %>"><%= u_title %></option>
<% end if %>
<option value="Average">Average</option>
<option value="Max">Max</option>
<option value="Min">Min</option>
<option value="Sum">Sum</option>
<option value="Count">Count</option>
<option value="Detail">Detail</option>
<input type="submit" value="Submit">




ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3