Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Group by: Not getting expected output
Carlos wrote:
> >>I doubt very much it does.
>
> You, faithless man! ;-)
>
> Of course it does:
>
> <snip>
>
> A long time ago in a galaxy far, far away (Oracle 7)... there were no
> CASE sentences...
And if you wanted to do it efficiently in Oracle 7 without reading the table twice, you could use decode and sign.
SQL> select deptno,
2 count(decode(sign(sal - 1201), -1, null, 3 decode(sign(sal - 2000), -1, 1))) count4 from emp
DEPTNO COUNT
---------- ----------
10 1 20 0 30 4Received on Fri May 12 2006 - 08:04:17 CDT