这段语句中为什么 老是报错 ‘HAVING avgAge>17; ’?

SELECT addr,

GROUP_CONCAT(username) AS userDetail,

COUNT(*) AS totalUsers,

SUM(age) AS sunAge,

MAX(age) AS maxAge,

MIN(age) AS minAge,

AVG(age) AS avgAge 

FROM user1 

WHERE id >= 2 

GROUP by addr

ORDER BY avgAge         

HAVING avgAge>17;   


慕粉3541299
浏览 1439回答 2
2回答

产品经理不是经理

HAVING放在ORDER BY前面GROUP BY后面。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL