Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Averaging scores 1

Status
Not open for further replies.

Yukonbanzai

Technical User
Joined
Mar 18, 2004
Messages
36
Location
CA
I'm trying to create a table or whatever to calculate cadet shooting averages.
Need to calculate for 30 to 40 shooters with a min of 50 scores each. Goal is to have a running average that updates as new scores are entered.

Any help appreciated
 
Sorry, also should mention that it hi lights the first semi colon where I click OK
 
I'm taking a stab at this: I think that every field that is not in an Aggregate function must be in the GROUP BY expression, though the error text doesn't really help with that conclusion:
Code:
SELECT Cadet.HealthCare, Cadet.FirstName, Cadet.LastName, ;
       AVG(Grpng.g1) as AvgScore ;
   FROM Cadet, Grpng ;
   WHERE Cadet.HealthCare = Grpng.HealthCare ;
   GROUP BY Cadet.HealthCare, Cadet.FirstName, Cadet.LastName ;
   INTO CURSOR AvgScores
 
copied and pasted and still get the same error message at the first semi-colon.

Just to make sure I'm not the problem:
I open my select query in SQL view and paste this code in...Right?
 
Tried a different approach and ended up with this code:

SELECT Cadet.HealthCare, Cadet.LastName, Cadet.FirstName, Avg(Grpng.G1) AS AvgOfG1
FROM Cadet LEFT JOIN Grpng ON Cadet.HealthCare=Grpng.HealthCare
GROUP BY Cadet.HealthCare, Cadet.LastName, Cadet.FirstName;

Created a form with the scores as a sub-form. Does what I want with the exception that as I enter ther scores, the average does not update until I close the form. Tried the "save record" and "refresh form" command buttons without success.
 
I believe at the location you're using it (in a view), you want to leave the "INTO CURSOR AvgScores" off.

I was assuming the SQL code was being executed in a program.

I don't have much experience with views, so I'm not sure of how to force it to update.... since VFP doesn't have "sub Forms", I assume you mean the scores are in a Grid. You could try firing the "Requery" method of the Grid showing the Averages... ("refresh" doesn't cause a Requery... but Requery does.)
 
Just a stab in the dark...is it possible that the code directly above this SQL statement ends with a semi-colon? If so, even if it is commented out code, remove that semi-colon! If not, then we have ruled out another cause for the problems you are having.

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
WHAT? Yukonbanzai, where is this code being used? I mean where are you typing it in at, exactly?

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
I owe all an apology. I'm working in Access not VFP.
The information I got here was helpful though.

I've been called a lot of things, but bright was probably not one of them.

Again, sorry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top