Convert row to comma separated column

Posted on 2006-04-24
Last Modified: 2008-03-03

I have a table in oracle

Name    Task
------     ------
A           1
B           2
B           3
B           4
C           5
D           6
C           7

I want the output in following format

Name     Task
A            1
B            2,3,4
C            5,7
D            6

Can i get it in a single SQL without using any user function.

Question by:vishalgoyal123
    LVL 27

    Expert Comment

    It's better to place your question to DB->Oracle
    LVL 14

    Accepted Solution

    I think there is no aggregate function that would do this using a single SQL statement.
    To obtain the desired output, you need to process data using a cursor and some temporary variables.


      Nayer Naguib

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    Suggested Solutions

    Title # Comments Views Activity
    MaxSpan challenge 9 50
    thread-safe code in c++ 2 58
    scoreUp challenge 14 40
    wordmultiple challenge 12 62
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    A short article about problems I had with the new location API and permissions in Marshmallow
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now