mysql 错误。 #1111 - Invalid use of group function

// #1242 - Subquery returns more than 1 row
SELECT (sum(view)-max(view)-min(view))/(count(media_id)-2),count(media_id) 
FROM ms_media_share as a 
WHERE ( select count(media_id) from ms_media_share group by media_id ) 
NOT IN (1,2,3) 
GROUP BY media_id

// #1111 - Invalid use of group function
SELECT (sum(view)-max(view)-min(view))/(count(media_id)-2),count(media_id) 
FROM ms_media_share as a 
WHERE count(media_id) > 3
GROUP BY media_id

// 可行
SELECT (sum(view)-max(view)-min(view))/(count(media_id)-2),count(media_id) 
FROM ms_media_share as a 
GROUP BY media_id

求助,谁知道原因的麻烦告诉一下,谢谢

阅读 18.2k
1 个回答

你不可能同时又group by一列,同时又要去count这同一列,你要想count的话,count别的列才行。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏