Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: DECODE
>> SELECT DECODE (deptno,10, 'ACCOUNTING',
20, 'RESEARCH', 30, 'OPERATION', 40, 'OPERATION', 'NONE')COUNT(*)
is there anyway for me to group by the decoded values rather than the original stored values ? <<
If I understnad what you want, try this:
SELECT SUM(DECODE (deptno, 10, 1, 0))AS Accounting, SUM(DECODE (deptno, 20, 1, 0)) AS Research, SUM(DECODE (deptno, 30, 1, 40, 1, 0) AS Operations, (COUNT(*) - (Accounting + Research + Operations)) AS noneFROM TableA;
--CELKO--
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Feb 11 2000 - 09:49:47 CST