sql - Convert rows into columns using pivot in oracle 11g -
i want convert rows columns using pivot function.
example below
table
emp no emp name ------- -------- 1 abc 2 pqr output should
col1 col2 ---- ---- emp no 1 emp name abc emp no 2 emp name pqr i ok loop , should have used pivot, have serached google has not got matching.
please suggest , send sample code.
actually requirement, need unpivot, not pivot. that, datatype of both columns should same, character in case
with tab(emp_no, emp_name) ( select '1' ,'abc' dual union select '2' ,'pqr' dual) ---- --end of data perparation ---- select * tab unpivot (col2 col1 in ( emp_no 'emp no', emp_name 'emp name')); output
| col1 | col2 | |----------|------| | emp no | 1 | | emp name | abc | | emp no | 2 | | emp name | pqr |
Comments
Post a Comment