If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Comma-separation in a query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-11, 21:28
Zettai Baka Zettai Baka is offline
Registered User
 
Join Date: Jul 2011
Posts: 1
Comma-separation in a query

Hello!

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!
Reply With Quote
  #2 (permalink)  
Old 07-15-11, 03:15
rski rski is offline
Registered User
 
Join Date: Nov 2006
Posts: 82
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On