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 27 28 29 30 31 32 33
| With MaTable as
(
select 'AAA' as nom, 'P2-1' as mat, to_date('13/01/10', 'dd/mm/rr') as date_exam from dual union all
select 'AAA' , 'PE01' , to_date('14/01/10', 'dd/mm/rr') from dual union all
select 'AAA' , 'P201' , to_date('14/01/10', 'dd/mm/rr') from dual union all
select 'BBB' , 'P2-1' , to_date('16/01/10', 'dd/mm/rr') from dual union all
select 'BBB' , 'PE01' , to_date('16/01/10', 'dd/mm/rr') from dual union all
select 'BBB' , 'P201' , to_date('16/01/10', 'dd/mm/rr') from dual union all
select 'CCC' , 'P2-1' , to_date('14/01/10', 'dd/mm/rr') from dual union all
select 'CCC' , 'PE01' , to_date('15/01/10', 'dd/mm/rr') from dual union all
select 'CCC' , 'P201' , to_date('15/01/10', 'dd/mm/rr') from dual union all
select 'DDD' , 'P2-1' , to_date('11/01/10', 'dd/mm/rr') from dual union all
select 'DDD' , 'PE01' , to_date('12/01/10', 'dd/mm/rr') from dual union all
select 'DDD' , 'P201' , to_date('12/01/10', 'dd/mm/rr') from dual
)
select nom, mat, to_char(date_exam, 'dd/mm/rr') as date_exam
from matable
order by min(date_exam) over(partition by nom) asc,
nom, date_exam;
NOM MAT DATE_EXAM
DDD P2-1 11/01/10
DDD PE01 12/01/10
DDD P201 12/01/10
AAA P2-1 13/01/10
AAA P201 14/01/10
AAA PE01 14/01/10
CCC P2-1 14/01/10
CCC P201 15/01/10
CCC PE01 15/01/10
BBB P2-1 16/01/10
BBB PE01 16/01/10
BBB P201 16/01/10 |
Partager