Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Query Question
Matthias Gresz schrieb:
>
> Hi,
>
> maybe this statement form Juri Modic give you some hints:
>
> SELECT a.deptno, a.sal sumsal, ROWNUM ranking FROM
> (SELECT deptno, SUM(sal) sal FROM emp GROUP BY deptno) a,
> dual
> WHERE -1*a.sal = DECODE(dual.dummy(+),'X',0,0)
> AND ROWNUM <= 3
> /
>
Could you elaborate on that statement a bit, maybe it's just a typo, but
as it is
I have a hard time seeing what the WHERE clause does. (Isn't it always
evaluating to true?)
Besides it doesn't give a correct ranking by sumsal:
SQL> SELECT a.deptno, a.sal sumsal, ROWNUM ranking FROM
(SELECT deptno, SUM(sal) sal FROM emp GROUP BY deptno) a,
dual
WHERE -1*a.sal = DECODE(dual.dummy(+),'X',0,0)
AND ROWNUM <= 3;
DEPTNO SUMSAL RANKING
---------- ---------- ----------
10 8750 1 20 10875 2 30 9400 3
Thanks
Christian Received on Fri Apr 17 1998 - 08:42:04 CDT
![]() |
![]() |