Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: RE: select average score PLUS other items


Message #1 by stephen.eighmey@s... on Tue, 5 Mar 2002 19:16:17
thank you so much for your help. i actually found an easier way to do it. 

i just use the same WHERE clause in a second select statement for the 

score averages. it works great!
Message #2 by "Peter Foti (PeterF)" <PeterF@S...> on Tue, 5 Mar 2002 13:28:31 -0500
It sounds like you are looping through all of the records to display

them on the page, so while you are looping, just add the values to some

variables.  For example:



<%

Dim testAvg

Dim recordCount



' Initialize variables

testAvg = 0

recordCount = 0



' Start loop here (omitted)

   ' Print out dates, names, scores, etc. (omitted)



   ' Add score to testAvg

   testAvg = testAvg + testAvg



   ' Increment total count

   recordCount = recordCount + 1



' End loop here (omitted)



' Calculate the average test score

testAvg = testAvg / recordCount



' Print the average test score

Response.Write("Average Score: " & testAvg)

%>



Hope this helps.

Pete





> -----Original Message-----

> From: stephen.eighmey@s... 

> [mailto:stephen.eighmey@s...]

> Sent: Tuesday, March 05, 2002 5:41 PM

> To: ASP Databases

> Subject: [asp_databases] select average score PLUS other items

> 

> 

> hello,

> 

>    i have a page that displays dates, names, etc... AND 

> scores from a test 

> result, which come from a database. at the end of the page i 

> need to show 

> the average of these scores that are just on that page. i 

> know i can use 

> an aggregate function in the select statement for that 

> particular field 

> but how do i show this average if i want to show other data 

> as well that 

> is not averaged? thank you in advance for any help.




> $subst('Email.Unsub').

> 

Message #3 by stephen.eighmey@s... on Tue, 5 Mar 2002 18:06:47
 i should also mention that my data type is interger for this field.
Message #4 by stephen.eighmey@s... on Tue, 5 Mar 2002 17:41:25
hello,



   i have a page that displays dates, names, etc... AND scores from a test 

result, which come from a database. at the end of the page i need to show 

the average of these scores that are just on that page. i know i can use 

an aggregate function in the select statement for that particular field 

but how do i show this average if i want to show other data as well that 

is not averaged? thank you in advance for any help.

  Return to Index