Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Case statement in Group by ?

Re: Case statement in Group by ?

From: <mikharakiri_nospaum_at_yahoo.com>
Date: 10 Feb 2005 12:03:45 -0800
Message-ID: <1108065825.902462.36290@f14g2000cwb.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US