This topic is locked

Column Average

2/22/2004 11:31:48 PM
ASPRunnerPro General questions
C
chhuey1 author

Hi,
Wondering how to get an average of a column?
Each row has a different numerical value. I'd like to be able to display the average of these values in the bottom row of the table.
Is this possible?
Thanks!

Sergey Kornilov 2/23/2004

Hi,
I would add the following snippet of code after the main table with results displayed. You will need to replace column names and table names accordingly.

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open
Set rsAvg = server.CreateObject ("ADODB.Recordset")

strSQL = "select  from Avg(col1) as Avg1, Avg(col2) as Avg2, Avg(col3) as Avg3 from TableName"

rsAvg.open strSQL, dbConnection

Response.Write rsAvg("Avg1")

Response.Write rsAvg("Avg2")

Response.Write rsAvg("Avg3")

rsAvg.Close

set rsAvg = Nothing

dbConnection.Close

set dbConnection = nothing


Let me know if you need some help implementing this.

C
chhuey1 author 2/23/2004

Hi Sergey,
Thanks for the response.
Looks like I am going to need some help with this.
The numeric values are all listed in the same column "Scores". I need an average of the column, even if it's dynamic and changes depending on the search criteria.
Thanks again!

Sergey Kornilov 2/23/2004

I see what's you saying.
Please zip and send me all files from ASPRunner's output folder with subfolders including your sample database. Just send it to support AT xlinesoft.com. I'll make changes and send it back to you.