CREATE TABLE Average_Professor
SELECT ie.Instructor
,SUM(ie.instreffective_avg + h.howmuchlearned_avg + ir.instrrespect_avg +
iv.instroverall_avg + av.availability_avg)/5
FROM instreffective_average ie
JOIN howmuchlearned_average h USING (Instructor)
JOIN instrrespect_average ir USING (Instructor)
JOIN instructoroverall_average iv USING (Instructor)
JOIN availability_average av USING (Instructor)
GROUP BY Instructor
它给了我错误代码1166。如果省略“CREATE TABLE Professor_average”,则脚本将运行,但我没有创建表。
最佳答案
尝试命名计算列:
CREATE TABLE Average_Professor
SELECT ie.Instructor
,SUM(ie.instreffective_avg + h.howmuchlearned_avg + ir.instrrespect_avg +
iv.instroverall_avg + av.availability_avg)/5 as calculation_value
FROM instreffective_average ie
JOIN howmuchlearned_average h USING (Instructor)
JOIN instrrespect_average ir USING (Instructor)
JOIN instructoroverall_average iv USING (Instructor)
JOIN availability_average av USING (Instructor)
GROUP BY Instructor
关于mysql - 如何创建一个新表,根据名称获取其他表中列的平均值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14802343/