“Joe的经理想要按部门分组的员工信息, 按性别分组,另外由部门和性别组合。仅限列表 那些在以D字母开头的部门工作的人。 列出部门,性别,工资总额,最低工资和最高工资 工资“。
所以基本上,我需要3组。 但我似乎无法将GROUP BY WorkDept与Sex结合起来。
这对我不起作用:
SELECT WORKDEPT, SUM(SALARY) AS SALARY_SUM, MIN(SALARY) AS MIN_SALARY,
MAX(SALARY) AS MAX_SALARY
FROM EMPLOYEE
WHERE WORKDEPT LIKE 'D%'
GROUP BY CUBE(WORKDEPT, SEX);
谢谢!
答案 0 :(得分:0)
我认为其他人是对的,你可能会使问题过于复杂。但是,如果您打算使用cube
,请尝试with cube
。像这样......
select
WORKDEPT,
sum(SALARY) as SALARY_SUM,
min(SALARY) as MIN_SALARY,
max(SALARY) as MAX_SALARY
from EMPLOYEE
where WORKDEPT LIKE 'D%'
group by WORKDEPT, SEX
with cube