DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: how to get this

  1. #1
    Join Date
    Dec 2002
    Posts
    110

    how to get this

    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

  2. #2
    Join Date
    May 2002
    Posts
    2,645
    select who||why||when||etc from table;

  3. #3
    Join Date
    Dec 2002
    Posts
    110

    how to get this

    What i meant by the question is i want all rows of a table in a column to be displayed on a single row

  4. #4
    Join Date
    Nov 2002
    Location
    New Delhi, INDIA
    Posts
    1,796
    I did something like this

    Code:
    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
    Amar
    "There is a difference between knowing the path and walking the path."

    Amar's Blog  Get Firefox!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width