Click to See Complete Forum and Search --> : how to get this


zulu99
02-21-2003, 12:43 AM
hi all

i have a table , contents of which is something like this

Who
why
when
what
how

above are different rows in the table

Now i wnat all the 5 rows to be displayed as 1 row . how to get this

Thanks

stecal
02-21-2003, 12:46 AM
select who||why||when||etc from table;

zulu99
02-21-2003, 09:23 AM
What i meant by the question is i want all rows of a table in a column to be displayed on a single row

adewri
02-21-2003, 11:17 AM
I did something like this


SQL> create table test1 (Ename varchar2(10));

Table created.


SQL> insert into test1 values('&ENAME');
Enter value for ename: Amar
old 1: insert into test1 values('&ENAME')
new 1: insert into test1 values('Amar')

1 row created.

SQL> /
Enter value for ename: Test
old 1: insert into test1 values('&ENAME')
new 1: insert into test1 values('Test')

1 row created.

SQL> /
Enter value for ename: Why
old 1: insert into test1 values('&ENAME')
new 1: insert into test1 values('Why')

1 row created.

SQL> /
Enter value for ename: David
old 1: insert into test1 values('&ENAME')
new 1: insert into test1 values('David')

1 row created.

SQL> commit;

Commit complete.

SQL> select * from test1;

ENAME
------------------------------
Amar
Test
Why
David

SQL> set lines 2000

SQL> select t3.ename,t2.ename,t1.ename
2 from
3 test1 t1,test1 t2,test1 t3
4 where
5 t1.ename <> t2.ename
6 and
7 t2.ename <> t3.ename
8 and
9 t3.ename <> t1.ename
10 and rownum < 2;

ENAME ENAME ENAME
------------------------------ ------------------------------ ------------------------------
Amar Test Why



Other method would be to use PL/SQL procedure...

HTH