判断一下sql语句的错误:select avg(Age) as s_age,TeacherID from student group by TeacherID having s_age>12;
时间: 2024-04-20 19:23:51 浏览: 64
SQL语句常见错误
这个 SQL 语句有一个错误。在 HAVING 子句中,你不能直接使用别名 s_age,而应该使用聚合函数 avg(Age)。正确的 SQL 语句应该是:
SELECT AVG(Age) AS s_age, TeacherID
FROM student
GROUP BY TeacherID
HAVING AVG(Age) > 12;
阅读全文