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 -> newbie problem with analytic function

newbie problem with analytic function

From: <ravi.superiors_at_gmail.com>
Date: 2 Aug 2006 04:11:42 -0700
Message-ID: <1154517102.336787.157700@i42g2000cwa.googlegroups.com>


hi

i am newbie in oracle and facing a lilttle problem please help me

when i run this query it gives me correct result

  1* select deptno,sal,sum(sal) over (partition by deptno order by empno) "sal" from e
SQL> /

DEPTNO        SAL        sal
---------         ----------- ----------
        10       2450       2450
                  5000       7450
                  1300       8750
        20      1000       1000
                  2975       3975
                  3000       6975
                  1100       8075
                  3000      11075
        30      1600       1600
                 1250       2850
                 3000       5850

14 rows selected.

but when i dont use order by clause it gives me wrong result as follows

  1* select deptno,sal,sum(sal) over (partition by deptno) "sal" from emp
SQL> /

    DEPTNO        SAL        sal
----------           ---------- ----------
        10          2450       8750
                     5000       8750
                     1300       8750
        20         1000      11075
                    1100      11075
                    3000      11075
                    3000      11075
                    2975      11075
        30        1600      11150
                   2850      11150
                   3000      11150

what is the role of order by clause in analytic function?

ravi Received on Wed Aug 02 2006 - 06:11:42 CDT

Original text of this message

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