gpt4 book ai didi

mysql - #1111 - 组函数 : MAX COUNT doesn't work with MYSQL5. 5 的使用无效

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:52 25 4
gpt4 key购买 nike

我有一个表userInteret,我想选择用户之间的最大公共(public)interet。我试过这个查询:

SELECT nomInteretUser,idUser,COUNT(nomInteretUser) FROM `userInteret` 
WHERE nomInteretUser IN('piano','flute','chien') GROUP BY idUser

但是当我尝试这个时,我想要这个 COUNT 的最大值:

SELECT MAX(COUNT(nomInteretUser))FROM userInteret 
WHERE nomInteretUser IN('piano','flute','chien') GROUP BY idUser;

总是出错:

MySQL a répondu: Documentation

1111 - Invalid use of group function

最佳答案

SELECT idUser,COUNT(nomInteretUser) counts 
FROM userInteret
WHERE nomInteretUser IN('piano','flute','chien')
GROUP BY idUser
ORDER BY counts DESC LIMIT 1

关于mysql - #1111 - 组函数 : MAX COUNT doesn't work with MYSQL5. 5 的使用无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37049205/

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