Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    1

    Unanswered: is this a bug? about analytic function.

    create table emp (
    empno varchar2(10),
    deptno varchar2(10),
    sal number(10)
    )


    insert into emp(empno,deptno,sal) values('1','10',101);
    insert into emp(empno,deptno,sal) values('2','20',102);
    insert into emp(empno,deptno,sal) values('3','20',103);
    insert into emp(empno,deptno,sal) values('4','10',104);
    insert into emp(empno,deptno,sal) values('5','30',105);
    insert into emp(empno,deptno,sal) values('6','30',106);
    insert into emp(empno,deptno,sal) values('7','30',107);
    insert into emp(empno,deptno,sal) values('8','40',108);
    insert into emp(empno,deptno,sal) values('9','30',109);
    insert into emp(empno,deptno,sal) values('10','30',110);
    insert into emp(empno,deptno,sal) values('11','30',100);


    SELECT empno, deptno, sal,
    last_value(sal)
    OVER (PARTITION BY deptno order by sal desc) col1,
    first_value(sal)
    OVER (PARTITION BY deptno order by sal asc) col2,
    first_value(sal)
    OVER (PARTITION BY deptno order by sal desc) col3,
    last_value(sal)
    OVER (PARTITION BY deptno order by sal asc) col4
    FROM emp


    col2, col3 return what I expect.


    I don't know why col1 and col4 return the these kinds of results.

    I use oracle 9i.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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