Home » SQL & PL/SQL » SQL & PL/SQL » Rows into Columns
Rows into Columns [message #2273] Wed, 03 July 2002 04:10 Go to next message
balasubramanian r
Messages: 2
Registered: July 2002
Junior Member
Hi,
Can anybody tell how to convert rows into columns without using Decode Function in Sql?
Re: Rows into Columns [message #2274 is a reply to message #2273] Wed, 03 July 2002 06:19 Go to previous messageGo to next message
Balaji
Messages: 102
Registered: October 2000
Senior Member
try this in pl/sql.

SQL> select ename from emp;

ENAME
--------------------
SACHIN
GANGULY
DRAVID
ZAHEER KHAN
YUVRAJ SINGH
SEHWAG
DINESH MONGIA
ANIL KUMBLE
AGARKAR

9 rows selected.

SQL> set linesize 200
SQL> declare
2 cursor c1 is select ename from emp;
3 rowdet varchar2(1000);
4 empnodet c1%rowtype;
5 begin
6 open c1;
7 loop
8 fetch c1 into empnodet;
9 rowdet :=rowdet ||' ' ||empnodet.ename;
10 exit when c1%notfound;
11 end loop;
12 dbms_output.put_line(rowdet);
13 end;
14 /
SACHIN GANGULY DRAVID ZAHEER KHAN YUVRAJ SINGH SEHWAG DINESH MONGIA ANIL KUMBLE AGARKAR

rgds
Balaji.K.L
Re: Rows into Columns [message #2304 is a reply to message #2273] Thu, 04 July 2002 01:09 Go to previous message
balasubramanian r
Messages: 2
Registered: July 2002
Junior Member
Hi,
Thanks for the solution. But I want it as Sql statment only without using decode function, and not in PL/SQL

Thanks,

R. Balasubramanian
Previous Topic: transpose
Next Topic: quries
Goto Forum:
  


Current Time: Wed Apr 24 07:51:37 CDT 2024