Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    39

    Unanswered: Multiple Row Out Pun In Single Row

    how can I take LE ROW OUT PUN IN SINGLE ROW;
    Example :
    create Table emp(name varchar2(10) );
    insert 4 rows;


    SELECT NAME FROM EMP .. GIVES YOU OUTPUT :
    JOHN
    TOM
    BOB
    RICK

    how can I get out put on one line in sql.
    JOHN, TOM, BOB, RICK

    Thanks
    ydj

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Well, if your table had one more column and if it was unique and - furthermore - you knew definite list of its values, I might suggest you some kind of solution ... perhaps it'll help you find your way:
    Code:
    SQL> create table my_table (id number, name varchar2(10));
    
    Table created.
    
    SQL> insert into my_table values (1, 'John');
    
    1 row created.
    
    SQL> insert into my_table values (2, 'Tom');
    
    1 row created.
    
    SQL> insert into my_table values (3, 'Bob');
    
    1 row created.
    
    SQL> select max(decode(id, 1, name)) n1,
      2         max(decode(id, 2, name)) n2,
      3         max(decode(id, 3, name)) n3
      4  from my_table;
    
    N1         N2         N3
    ---------- ---------- ----------
    John       Tom        Bob
    
    SQL>
    Or its modification:
    Code:
    SQL> select max(decode(id, 1, name)) ||', '||
      2         max(decode(id, 2, name)) ||', '||
      3         max(decode(id, 3, name)) n
      4  from my_table;
    
    N
    ----------------------------------
    John, Tom, Bob
    Unfortunately, I wouldn't know how to do this using your original table.
    Last edited by Littlefoot; 02-11-05 at 02:52.

  3. #3
    Join Date
    Mar 2002
    Location
    Reading, UK
    Posts
    1,137
    Look up stragg in google.

    Alan

  4. #4
    Join Date
    Nov 2003
    Posts
    39
    Great!! It works exactly I wanted,
    Thanks

Posting Permissions

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