mysql - #1111 SQL 中 Group 函数的使用无效 : Concept?

标签 mysql sql syntax-error

我正在尝试运行以下 SQL 代码,该代码会生成过去 3 天的平均问题。但是,我收到 #1111 invalid use of group function 错误。不知道我哪里出错了。即使我删除了该组,这仍然存在。请帮忙。

select BookId, ChapterName, AuthorCountry,
       avg(sum(No_of_issues)) as last3dayavgissues
from library_data
where Date between (select max(Date) from library_data) and
                   (select (max(Date)-3) from library_data) 
group by BookId, ChapterName 
having (AuthorCountry='US' OR AuthorCountry='DE')) 
group by BookId, ChapterName 
order by AuthorName
into outfile 'C:/output files/abc.csv'
        fields terminated by '\t'
        lines terminated by '\n';

谢谢 视频

最佳答案

在 avg 函数中使用 sum 函数会导致组函数无效使用错误。sum 函数仅返回一个值,单个值的平均值没有意义。

关于mysql - #1111 SQL 中 Group 函数的使用无效 : Concept?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21251929/

相关文章:

sql - INT或附近的PostgreSQL语法错误

mySQL >> 将 HREF 链接添加到不同的 GROUP_CONCAT

当我使用count时Mysql返回0

mysql - 查看两个表之间所有可能的组合

python - 原始查询和自定义 sql 查询最快的是什么?

c# - 使用 C# 在 sql 数据库中插入日期时间值

php - 这些 strtotime() 格式是否存在?

mysql - WordPress DB 查询以计算每天注册的用户数

python-2.7 - 令人沮丧的python语法错误

c# - 按返回类型重载?