Error 404
Error 404

Reputation: 429

Syntax error: missing `closing parenthesis` MySQL

I don't know way I got this error message here:

enter image description here

Here is the query:

SELECT t1.*,t2.totalAvg, ABS(`average for this subject`-totalAvg)  AS Difference, 100*MIN(`average for this subject`,totalAvg)/MAX(`average for this subject`,totalAvg) AS precent
FROM (SELECT StudentFirstName,StudentLastName,ClassName,AVG(Grade) AS `average for this subject`
      FROM tests
      INNER JOIN students ON tests.StudentID=students.StudentID
      GROUP BY StudentFirstName,StudentLastName,ClassName
     ) t1
JOIN (SELECT StudentFirstName,StudentLastName,AVG(`average for this subject`) as totalAvg
      FROM (SELECT StudentFirstName,StudentLastName,ClassName,AVG(Grade) AS `average for this subject`
            FROM tests
            INNER JOIN students ON tests.StudentID=students.StudentID
            GROUP BY StudentFirstName,StudentLastName,ClassName
           ) t
      GROUP BY StudentFirstName,StudentLastName
     ) t2 
ON t1.StudentFirstName=t2.StudentFirstName and t1.StudentLastName=t2.StudentLastName

Upvotes: 2

Views: 3789

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269483

Your code may have other errors, but this is definitely incorrect in MySQL:

MIN(`average for this subject`, totalAvg)

MIN() only takes one argument. Presumably, you want LEAST():

LEAST(`average for this subject`, totalAvg)

Upvotes: 3

Related Questions