Subject | Re: FB30 question about row_number |
---|---|
Author | philippe makowski |
Post date | 2013-08-08T16:22:55Z |
liviuslivius [2013-08-07 09:43] :
select emp_no, dept_no, salary,
rank() over (order by salary desc nulls last),
dense_rank() over (order by salary desc nulls last),
row_number() over (order by salary desc nulls last)
from employee;
EMP_NO DEPT_NO SALARY RANK DENSE_RANK ROW_NUMBER
======= ======= ============= ======= ============= =============
121 125 99000000.00 1 1 1
118 115 7480000.00 2 2 2
110 115 6000000.00 3 3 3
134 123 390500.00 4 4 4
105 000 212850.00 5 5 5
46 900 116100.00 6 6 6
85 100 111262.50 7 7 7
107 670 111262.50 7 7 8
141 121 110000.00 9 8 9
> Hi,here an example :
>
> i have question about row_number window function
> what it numerate records processed or records in retrieval order?
>
> i have query where result is like this
>
> Dense_rank Rank Row_Number
> 1 1 2
> 1 1 4
> 1 1 3
> 1 1 1
> ......
>
> should i do order by row_number column to get it in 1, 2, 3, 4.. or this an error?
>
select emp_no, dept_no, salary,
rank() over (order by salary desc nulls last),
dense_rank() over (order by salary desc nulls last),
row_number() over (order by salary desc nulls last)
from employee;
EMP_NO DEPT_NO SALARY RANK DENSE_RANK ROW_NUMBER
======= ======= ============= ======= ============= =============
121 125 99000000.00 1 1 1
118 115 7480000.00 2 2 2
110 115 6000000.00 3 3 3
134 123 390500.00 4 4 4
105 000 212850.00 5 5 5
46 900 116100.00 6 6 6
85 100 111262.50 7 7 7
107 670 111262.50 7 7 8
141 121 110000.00 9 8 9