1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| SQL> with t as (
2 select 'id1' as id, 'f_11' as filiere1, 'f_21' as filiere2, 'p1' as periode from dual union all
3 select 'id1' , 'f_12' , 'f_22' , 'p2' from dual union all
4 select 'id2' , 'f_11' , NULL , 'p1' from dual
5 )
6 select id,
7 max(case when periode = 'p1' then filiere1 end) as filiere1_P1,
8 max(case when periode = 'p2' then filiere1 end) as filiere1_P2,
9 max(case when periode = 'p1' then filiere2 end) as filiere2_P1,
10 max(case when periode = 'p2' then filiere2 end) as filiere2_P2
11 from t
12 group by id
13 order by id;
ID FILI FILI FILI FILI
--- ---- ---- ---- ----
id1 f_11 f_12 f_21 f_22
id2 f_11
SQL> |
Partager