0
我正在尝试运行下面的sql代码,它会生成最近3天的平均问题。但是,我越来越#1111 invalid use of group function error
。不知道我错在哪里。即使我将该群组删除,此操作仍会保留。请帮忙。#1111在SQL中使用组函数无效:Concept?
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';
感谢 阿维
你有两次组。 – Robbert
我试图重新格式化您的查询,但在'HAVING'子句的末尾似乎有一个额外的')' - 这实际上是您切出的较大查询的块(因为如果是这样,你向我们展示了内部查询和外部查询的一部分,所以它很混乱) –