SQL Language (MOSC)

MOSC Banner

Similar to UNPIVOT functionality in Oracle 10g

edited Mar 24, 2010 11:57PM in SQL Language (MOSC) 4 commentsAnswered
  Problem Description
--------------------------

One table is having DNO, LN1, LN2 --- LN89 columns along with other columns. Either 0 or 1 will be stored in LN1 to LN89 columns for each and every DNO.

Please go through below sample data for better understanding

Table
-------
CREATE TABLE COL2ROW
  (DNO NUMBER(6), LN1 NUMBER(1),
  LN2 NUMBER(1),LN3 NUMBER(1),
  LN4 NUMBER(1),LN5 NUMBER(1),
  LN6 NUMBER(1),LN7 NUMBER(1),
  LN8 NUMBER(1),LN9 NUMBER(1),LN10 NUMBER(1)) ;

Sample Data
------------
insert into col2row values( 111, 1,1,0,0,0,0,0,0,0,1);
insert into col2row values( 222, 0,1,1,1,0,1,0,0,0,0);
insert into col2row values( 333, 0,0,1,1,0,0,0,0,0,0);
insert into col2row values( 444, 1,0,0,1,0,0,0,0,1,0);
insert into col2row values( 555, 1,1,0,1,1,0,0,0,1,0);
insert into col2row values( 666, 0,0,0,1,1,1,0,0,1,0);

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center