Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011

    Unanswered: Comma-separation in a query


    I'm using PostgreSQL 9.0.4 and was wondering if someone could help me with a query.

    I have a table of graduates from a university that lists a graduate's names and degrees. The problem is, if a person has multiple degrees, multiple records are created. For example, if John Smith has three degrees, there would be three records such as:

    Smith | John | B.S Mathematics
    Smith | John | B.S Physics
    Smith | John | M.S Physics

    I want to combine these three records of the same person into one record, comma-separating their degrees. For example, the above three records should become one like this:

    Smith | John | B.S Mathematics, B.S Physics, M.S Physics

    I've come across the CONCAT function but I don't know how to adapt it for my particular situation. Another alternative is to do it via a programming language interface (I use the C# Npgsql interface to PostgreSQL). But I would like to do know how to do this with command-line SQL.

    Thanks in advance!

  2. #2
    Join Date
    Nov 2006

Posting Permissions

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