Subject | Odp: [firebird-support] Re: FB30 question about row_number |
---|---|
Author | liviuslivius@poczta.onet.pl |
Post date | 2013-08-08T20:24:32Z |
Hi,
I know how to do select with this, but i ask how should row_number work without specify order by in over clause. It numerate records in some internal order or it should numerate it in retrival order.
You do select an without order you should have always sequence 1 2 3 4? And only when you specify order in over clause you can get it as e.g. 2 4 1 3?
Regards,
Karol Bieniaszewski
----- Reply message -----
Od: "philippe makowski" <pmakowski@...>
Do: <firebird-support@yahoogroups.com>
Temat: [firebird-support] Re: FB30 question about row_number
Data: czw., sie 8, 2013 18:22
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
[Non-text portions of this message have been removed]
I know how to do select with this, but i ask how should row_number work without specify order by in over clause. It numerate records in some internal order or it should numerate it in retrival order.
You do select an without order you should have always sequence 1 2 3 4? And only when you specify order in over clause you can get it as e.g. 2 4 1 3?
Regards,
Karol Bieniaszewski
----- Reply message -----
Od: "philippe makowski" <pmakowski@...>
Do: <firebird-support@yahoogroups.com>
Temat: [firebird-support] Re: FB30 question about row_number
Data: czw., sie 8, 2013 18:22
liviuslivius [2013-08-07 09:43] :
> 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
[Non-text portions of this message have been removed]