Home » SQL & PL/SQL » SQL & PL/SQL » change columns into rows n rows into columns
change columns into rows n rows into columns [message #198135] Sun, 15 October 2006 13:54 Go to next message
oracle06
Messages: 36
Registered: December 2005
Member
Hello All,
what will be the SQL query to change columns into rows n rows
into columns.
Plz tell me.

Thanks.
Re: change columns into rows n rows into columns [message #198164 is a reply to message #198135] Sun, 15 October 2006 23:17 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
select column_as_row_n_row_as_column
from   your_table;

Your question is kind of vague..
You want us to put effort in answering you, please put some effort in asking what you are after first.
There is a so-called Sticky, it is the first post of the forum, that describes guidelines on how to post questions.
Re: change columns into rows n rows into columns [message #198202 is a reply to message #198164] Mon, 16 October 2006 02:57 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Also, there is a built-in which can be used as

SELECT DBMS_ROWCOL.TO_ROWS('table_name') FROM ...

and

SELECT DBMS_ROWCOL.TO_COLS('table_name') FROM ...

but, unfortunately, it works only in 10.2.0.1.778 version which is localized for Croatian market.

Another option is to rotate your monitor for 90 degrees - that way, all columns will become rows in a matter of seconds. Just be careful because pixels might fall out.


I'm just kidding http://www.orafaq.com/forum/fa/1597/0/

Although, there ARE questions of such a type - people usually want to convert columns to rows (search this Forum for "str2tbl" or "string_to_table"; here is one solution for the problem - if that's what you have in mind).

However, what do you mean "rows to columns"? I can't imagine that. Could you explain it a little bit better?
Re: change columns into rows n rows into columns [message #198206 is a reply to message #198135] Mon, 16 October 2006 03:17 Go to previous message
vijayanarayanan
Messages: 11
Registered: September 2006
Location: chennai
Junior Member
To populate column details into rows:
table 1

col1 col2 col3a col3b col3c

table 2

col1 col2 col3

if you want to populate all the contents of col3a,col3b,col3c
into col3 of table 2.Then

insert all
into table2(col1,col2,col3) values(col1,col2,[B]col3a)[/B[/COLOR]]
into table2((col1,col2,col3) values(col1,col2,col3b)
into table2((col1,col2,col3) values(col1,col2,col3c)
select col1,col2,col3a,col3b,col3c
from table1;


Previous Topic: SQl Query
Next Topic: sql query
Goto Forum:
  


Current Time: Sat Dec 03 01:22:54 CST 2016

Total time taken to generate the page: 0.06538 seconds