1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| with cte_data (commande, article, taille, quantite, montant) as
(
select '#0001', 'TeeShirt', 'S' , 10, 100 from dual union all
select '#0001', 'TeeShirt', 'M' , 20, 100 from dual union all
select '#0001', 'TeeShirt', 'L' , 30, 100 from dual union all
select '#0001', 'TeeShirt', 'XL', 40, 101 from dual
)
select *
pivot (sum(quantite) for taille in ( 'S' as s
, 'M' as m
, 'L' as l
, 'XL' as xl));
COMMANDE ARTICLE MONTANT S M L XL
-------- -------- ---------- ---------- ---------- ---------- ----------
#0001 TeeShirt 101 40
#0001 TeeShirt 100 10 20 30 |
Partager