gpt4 book ai didi

mysql - 语法错误 : missing `closing parenthesis` MySQL

转载 作者:行者123 更新时间:2023-11-29 05:57:49 25 4
gpt4 key购买 nike

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

enter image description here

查询如下:

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

最佳答案

你的代码可能还有其他错误,但这在MySQL中肯定是不正确的:

MIN(`average for this subject`, totalAvg)

MIN() 只接受一个参数。据推测,您需要 LEAST():

LEAST(`average for this subject`, totalAvg)

关于mysql - 语法错误 : missing `closing parenthesis` MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47722921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com