I want to calculate average of grades of each student with SQL command but I encounter problem with this code. I have 3 tables related to each other and want to calculate average of student grades. This is my SQL string but it dose not work.
What is the problem with this code? Please take a look at it.

Stri = "select student.StudentID,finalgrades.finalgrade, avg(FinalGrade)" _
& "FROM (student INNER JOIN CourseStudentJunc ON Student. StudentID = CourseStudentJunc.StudentID)" _
& " INNER JOIN FinalGrades on CourseStudentJunc.JuncID = FinalGrades.JuncID group by student. StudentID "
blStudent=student info(StudentID,name,...) 
tblcourseStudentJunc=Junction table for creating many to many relationship between course and student(JuncID,StudentID,CourseID) 
tblFinalGrades=saving grades of each student for each course separately (Juncid,Finalgrade)

Here is my requirement of this code:
1) First of all joining these tables
2) Calculating average of grades for each student

Recommended Answers

All 2 Replies

kindly post your table structures.

Hi I have a similar problem around these lines...

I have following tables:
class( class_id, class_name)
student(student_id, student_name, class_id)
exam ( exam_id , class_id , exam_date )
grade( exam_id , student_id, grade )

create a list of students and ther avg grade in their last N ( n can be any number ) tests

Any help in getting this sql will be useful

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.