Oracle
 sql >> Database >  >> RDS >> Oracle

Oracle 11g - Unpivot

Usa questa query:

with t (Dat, Year, Month, Day, Turn_1, Turn_2, Turn_3) as (
  select sysdate, 2014, 08, 28, 'Foo', 'Bar', 'Xab' from dual
)
select dat, year, month, day, turn, source from t
unpivot (
  source  for turn in (Turn_1, Turn_2, Turn_3)
)

DAT         YEAR    MONTH   DAY TURN    SOURCE
----------------------------------------------
08/01/2014  2014    8       28  TURN_1  Foo
08/01/2014  2014    8       28  TURN_2  Bar
08/01/2014  2014    8       28  TURN_3  Xab