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: query trigger

Re: query trigger

From: andrewst <member14183_at_dbforums.com>
Date: Tue, 20 May 2003 18:19:29 +0000
Message-ID: <2902410.1053454769@dbforums.com>

Originally posted by Daniel Morgan
> The ORDER BY in an in-line view accomplishes what?
>
> I mean other than wasting CPU.
> --
>

Er... it gets the result that was asked for? It may not be relationally pure, but it happens to work:

SQL> select deptno, sumsal from
  2 (
  3 select deptno, sum(sal) sumsal
  4 from emp
  5 group by deptno
  6 order by sumsal desc
  7 )
  8 where rownum = 1
  9 /

    DEPTNO SUMSAL
---------- ----------

        20 10875

  1 select deptno, sumsal from
  2 (
  3 select deptno, sum(sal) sumsal
  4 from emp
  5 group by deptno
  6 )
  7* where rownum = 1;

    DEPTNO SUMSAL
---------- ----------

        10 8750

With the ORDER BY you get the dept with the highest sumsal; without, you don't.

I'm surprised you didn't know that - or at least check it out before making sarcky comments ;)

--
Posted via http://dbforums.com
Received on Tue May 20 2003 - 13:19:29 CDT

Original text of this message

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