Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Case statement in Group by ?
How about cube operator:
select deptno, mgr, sum(sal), sum(comm) from emp group by cube(deptno, mgr);
You get the summaries by all the combinations of your attribute. Then you can filter the ones that you care. If deptno=null, then you get summaries grouped by mgr, if mgr = null then by deptno. Received on Thu Feb 10 2005 - 14:03:45 CST