After Oracle 11, there is a new method of row column conversion.
The following is the dredged code, please rest assured to use…
With AA as (
Select A,B,C,row_number() over (partition by B order by b) D from (
Select 10 A, 11 B, 12 C from dual
union
select 20,11,22 from dual
union
select 30 , 21 , 32 from dual )
)
Select * from AA pivot (Max(A) , Max(C) for B in (11,21))
remarks
Field B is supposed to determine the date. If you need a dynamic column, you can alias the max item, so that the dynamic column can be realized.
be careful
If the row and column conversion is not performed in the whole field, it is not necessary to add row_ number,
If it is added, some data will not be changed to the column because the row of the same item_ Number may be different.