Oracle query to convert multiple column into one column -


i have 50 column in table , returns 1 row , want 1 row 50 column displayed in 50 rows , 1 column.

can 1 suggest me oracle query it?

you can use unpivot 1 row column values

select colvalue    (   select *      table1   unpivot include nulls   (     colvalue cols in (col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, ... col50)   ) ); 

sample output:

 | colvalue | ------------ |        1 | |        2 | |   (null) | |..........| 

if need column column names pivoted table ditch outer select

select *    table1 unpivot include nulls (   colvalue cols in (col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, ... col50) ); 

sample output:

 |  cols | colvalue | -------------------- |  col1 |        1 | |  col2 |        2 | |  col3 |   (null) | | ..... |......... | 

here sqlfiddle demo


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -