Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: query trigger
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.comReceived on Tue May 20 2003 - 13:19:29 CDT