1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| With Commande AS
(
select 'c1' as cid, to_date('12/12/2009', 'dd/mm/yyyy') as cdt, 'A1' as csl from dual union all
select 'c5' , to_date('11/11/2009', 'dd/mm/yyyy') , 'B10' from dual union all
select 'c4' , to_date('19/12/2009', 'dd/mm/yyyy') , 'B11' from dual union all
select 'c1' , to_date('13/10/2010', 'dd/mm/yyyy') , 'Z12' from dual union all
select 'c5' , to_date('14/11/2010', 'dd/mm/yyyy') , 'Z13' from dual union all
select 'c1' , to_date('11/10/2010', 'dd/mm/yyyy') , 'A1' from dual
)
select dense_rank() over(order by cid asc) as rk,
cid, cdt, csl
from Commande
order by rk asc, cdt asc, csl asc;
RK CID CDT CSL
1 c1 12/12/2009 A1
1 c1 11/10/2010 A1
1 c1 13/10/2010 Z12
2 c4 19/12/2009 B11
3 c5 11/11/2009 B10
3 c5 14/11/2010 Z13 |
Partager