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

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Query Question

Re: SQL Query Question

From: kiel <kiel_at_webpre.com>
Date: Fri, 17 Apr 1998 08:42:04 -0500
Message-ID: <35375C2C.2BA8@webpre.com>


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

Original text of this message

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