Results 1 to 4 of 4

Thread: Problem-Specific SQL Query

  1. #1
    Join Date
    Jun 2005
    Posts
    1

    Problem-Specific SQL Query

    Hello Everyone,

    Please get me the solution for the problem specified below:

    Consider a table >

    Column Name A B

    23 g
    26 m
    23 h
    55 a
    26 k
    23 s

    I have to come up with a SQL query which can provide me with the output >

    23 g, h, s
    26 m, k
    55 a

    Regards,
    Rahul

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You have to write a cursor and a loop for this kind of output, it's not possible to do it using one sql statement.

  3. #3
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    Another option is to write a User Defined Function (if you are using SQL Server) which concats the fields like this.

  4. #4
    Join Date
    Mar 2003
    Posts
    468
    Oracle also has table functions.
    here is an article that show some of the functionality.
    not a solution to your particular problem but shows how they are constructed.
    http://www.databasejournal.com/featu...le.php/2222781

Posting Permissions

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