1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as mni
SQL>
SQL> With data As (
2 Select 1 id, 'titi' lib from dual union all
3 Select 2,'titi' from dual union all
4 Select 3,'tata' from dual union all
5 Select 4,'tutu' from dual union all
6 Select 5,'titi' from dual
7 )
8 Select id, lib, row_number() over(partition by lib order by id) - 1 cnt
9 from data
10 order by id
11 /
ID LIB CNT
---------- ---- ----------
1 titi 0
2 titi 1
3 tata 0
4 tutu 0
5 titi 2
SQL> |
Partager