Statistics questions

1. Junior Member
Join Date
Dec 1969
Posts
7

## Statistics questions

Hi, I&#039;m running a golfclub and have created an automated reporting system for the members, after the match their results are displayed in a nicely displayed ranked sheet. If u wanna check out what i&#039;ve done sofar using asp, check out our site at www.badboyzgolf.com , in particular the INHOUSE button.<BR>My question is this: how can I use the data to display statistics, sums, averages etc? I am sure there are good tutorials about this subject, if so, where can i find them?<BR>Happy New Year, Jan Hoekstra, Holland

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Depends on what you want to do...

You *can* get sums and averages directly from SQL:<BR><BR>SELECT Sum(score) AS totalScore, golferName FROM golfers GROUP BY golferName ORDER BY Sum(Score)<BR><BR>SELECT Avg(score) AS average, golferName FROM golfers GROUP BY golferName ORDER BY Avg(Score) <BR><BR>But if you do that, you won&#039;t get the individual scores at the same time. <BR><BR>So if you want to display *both* scores *and* totals/averages, you are better off just doing the calculations in VBScript:<BR><BR>&#060;%<BR>... make connection to DB ...<BR><BR>SQL = "SELECT golferName, gameNumber, score FROM golfers ORDER BY golferName, gameNumber"<BR>Set RS = conn.Execute( SQL )<BR><BR>priorGolfer = RS("golferName")<BR>sum = 0<BR>gameCount = 0<BR><BR>Do Until RS.EOF<BR>&nbsp; &nbsp; curGolfer = RS("golferName")<BR>&nbsp; &nbsp; If priorGolfer &#060;&#062; curGolfer Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write "Total score: " & sum & "&lt;BR&#062;"<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write "Average: " & (sum/gameCount) & vbNewLine<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write "&#060;HR&#062;Golfer: " & curGolfer & "&lt;"<BR>&nbsp; &nbsp; &nbsp; &nbsp; priorGolfer = curGolfer<BR>&nbsp; &nbsp; &nbsp; &nbsp; sum = 0<BR>&nbsp; &nbsp; &nbsp; &nbsp; gameCount = 0<BR>&nbsp; &nbsp; End If<BR>&nbsp; &nbsp; gnum = RS("gameNumber")<BR>&nbsp; &nbsp; score = RS("score")<BR>&nbsp; &nbsp; sum = sum + score<BR>&nbsp; &nbsp; gameCount = gameCount + 1<BR>&nbsp; &nbsp; Response.Write "game number " & gnum & ", score: " & score & "&lt;BR&#062;" & vbNewLine<BR><BR>&nbsp; &nbsp; RS.MoveNext<BR>Loop<BR>&#039; handle the last golfer!<BR>If sum &#060;&#062; 0 Then<BR>&nbsp; &nbsp; Response.Write "Total score: " & sum & "&lt;BR&#062;"<BR>&nbsp; &nbsp; Response.Write "Average: " & (sum/gameCount) & vbNewLine<BR>End If<BR>&<BR>%&#062;<BR>

3. Junior Member
Join Date
Dec 1969
Posts
7

## Thank you !

Thank you very much sir, this has been very helpfull, I had a few lines looking like that and it worked, but I think I really need to get into the basics of the code more and learn it better! I can go from here with your help, thanks again :)<BR>Jan

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•