CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


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 (@PointofSale.com) 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

<%
u_title=request.form("u_title")
' 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

accessdb="stocks" 
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">
<tr> 
<td>
Volume<br>(<%= u_title %>)
</td> 
</tr>
<%
rs.movefirst
do while not rs.eof
%>

<tr>
<td>
<%= formatnumber(rs("vol"),0) %>
</td>
</tr>
<%
rs.movenext
loop
%>

</table>
<% 
end if
%>

<form action="<%= request.servervariables("script_name") %>"
method="post">
<%
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>
</select><br><br>
<input type="submit" value="Submit">
</form><br>
</td></tr></table>
</td></tr></table>

 

 

 



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

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

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