#1111-无效使用组功能 [英] #1111 - Invalid use of group function

查看:87
本文介绍了#1111-无效使用组功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下查询来尝试获取从每个项目中检索最大数量的幻灯片的总数(总和),但是我收到以下错误(#1111-组功能的无效使用).这是查询:

I am using the following query in an attempt to get  total number(sum) of slides retrieving the max number from each project, however I am receiving the following error (#1111 - Invalid use of group function). Here's the query:

SELECT COALESCE(project,'Total') as Project, SUM(MAX(slides)) as Slides 
FROM projects_tbl 
WHERE date BETWEEN '2010-01-01' AND '2010-12-31' 
GROUP BY Project with ROLLUP

如果我删除了SUM(),那么它就起作用了,但是,对于所有的项目/幻灯片,我都没有准确的总数.

If I remove the SUM(), then the it works, however, I do not get an accurate total for all of the projects/slides.

预先感谢您的所有答复.

Thanks in advance for any and all replies.

推荐答案

SELECT  COALESCE(project,'Total') as Project, SUM(maxslides) AS slides
FROM    (
        SELECT  project, MAX(slides) as maxslides
        FROM    projects_tbl
        WHERE   date BETWEEN '2010-01-01' AND '2010-12-31' 
        GROUP BY
                project
        ) q
GROUP BY
        project WITH ROLLUP

这篇关于#1111-无效使用组功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆