Home » SQL & PL/SQL » SQL & PL/SQL » how to get rows of a table as columns
how to get rows of a table as columns [message #229890] Tue, 10 April 2007 04:39 Go to next message
meeta
Messages: 28
Registered: January 2000
Junior Member
Can anyone tell me how can i get rows of table as column
eg-> table abc
name age
a 23
b 13

I want the result as

name age name age
a 23 b 13

Re: how to get rows of a table as columns [message #229900 is a reply to message #229890] Tue, 10 April 2007 05:01 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> with lines as (select rownum line from dual connect by level <= 2 )
  2  select max(decode(line,1,name)) name,
  3         max(decode(line,1,age)) age,
  4         max(decode(line,2,name)) name,
  5         max(decode(line,2,age)) age
  6  from lines,
  7       (select name, age, rownum rn from abc)
  8  where rn = line
  9  /
NAME                        AGE NAME                        AGE
-------------------- ---------- -------------------- ----------
a                            23 b                            13

1 row selected.

Regards
Michel
Re: how to get rows of a table as columns [message #229915 is a reply to message #229900] Tue, 10 April 2007 05:30 Go to previous messageGo to next message
meeta
Messages: 28
Registered: January 2000
Junior Member
THANKS 4 UR REPLY
Re: how to get rows of a table as columns [message #230194 is a reply to message #229915] Wed, 11 April 2007 03:15 Go to previous messageGo to next message
pavuluri
Messages: 247
Registered: January 2007
Senior Member
i dont want create any table,

can we apply the same table.

example
asume that we create another table lines, we dont create line table.


only we can use sigle table

thanks,
srinivas

Re: how to get rows of a table as columns [message #230201 is a reply to message #230194] Wed, 11 April 2007 03:25 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Question
Really don't understand what you mean.
Post an example.

Regards
Michel
Previous Topic: REPLACE string in where clause
Next Topic: variables in packages
Goto Forum:
  


Current Time: Sun Dec 04 08:17:58 CST 2016

Total time taken to generate the page: 0.11049 seconds