Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    5

    Unanswered: Use of partion by

    Hi all

    I have to modify one of the existing Procedure , I'm not getting why the follwoing statement used for ,

    LEAD(ACTIVITY_TYPE,1) OVER (PARTITION BY UNIT_KEY ORDER BY UNIT_KEY,ACTIVITY_DATE)

    Can any one explain this.

    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    LEAD tells you what is coming up on the next row in the same "partition":
    Code:
    SQL> select deptno, empno, ename
      2  ,      lead(ename,1) over (partition by deptno order by empno) next
      3  from emp;
    
        DEPTNO      EMPNO ENAME      NEXT
    ---------- ---------- ---------- ----------
            10       7782 CLARK      KING
            10       7839 KING       MILLER
            10       7934 MILLER
            20       7369 SMITH      JONES
            20       7566 JONES      SCOTT
            20       7788 SCOTT      ADAMS
            20       7876 ADAMS      FORD
            20       7902 FORD
            30       7499 ALLEN      WARD
            30       7521 WARD       MARTIN
            30       7654 MARTIN     BLAKE
            30       7698 BLAKE      TURNER
            30       7844 TURNER     JAMES
            30       7900 JAMES
    You can read all about these "analytic functions" in the Oracle SQL Reference.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •