我正在使用以下查询,以尝试从每个项目中检索最大数量的幻灯片的总数(总和),但是我收到以下错误(#1111-组功能的无效使用)。这是查询:
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(),则它可以工作,但是,对于所有项目/幻灯片,我都无法获得准确的总数。
预先感谢您的所有答复。
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