LISTAGG Function

I had a requirement to rows of values in a comma-delimited list. I was thinking I would have to use some sort of arcane SQL functions or resort to PL/SQL when I came across a new function in Oracle 11.2 which fits the bill, namely LISTAGG.

Here is some sample data that I was able to return from one of our tables.

CustID PartID
5317751 5319609
5317761 5319699
5317781 5319673
5317781 12452932
5317781 14976021
5317801 5319637
5317801 11389825

For each CustID, if there was more than one PartID, then I needed the PartID values to be a comma-delimited list. I needed the output to look similar to the following:
It see for source cialis generika also is a significant predictor of the frequency of hospitalizations for acute exacerbations of COPD. They appreciate mastercard cialis online that both therapists share the same observations. Keep reading! By the end of this article is that erectile dysfunction medicines are not meant and should not be used for recreational purpose. cheap viagra in india Erectile dysfunction or ED becomes a challenging problem for a man who has recently married to a gal during his http://www.heritageihc.com/articles/15/ viagra cheap price 40s.
CustID PartsList
5317751 5319609
5317761 5319699
5317781 12452932,14976021,5319673
5317801 11389825,5319637

This is done quite nicely with the LISTAGG function. My SQL is as simple as follows:

SELECT custid, LISTAGG(partid,',') WITHIN GROUP (ORDER BY custid) AS partsList
FROM my_table
GROUP BY custid;