The LISTAGG function can be used in Oracle/PLSQL to solve this scenario.
For example:
product_id product_name
1001 Bananas
1002 Apples
1003 Pears
1004 Oranges
SELECT LISTAGG(product_name, ', ') WITHIN GROUP (ORDER BY product_name) "Product_Listing"
FROM products;
and it will show the following result:
Product_Listing
Apples, Bananas, Oranges, Pears
* Also another workaround can be applied when working with MySQL database. In this case the table can be exported to Local Storage and then run the query from there.
This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values. The full syntax is as follows:
GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [,col_name ...]]
[SEPARATOR str_val])
For example:
mysql> SELECT student_name,
GROUP_CONCAT(test_score)
FROM student
GROUP BY student_name;