How do I concatenate multiple rows into a single row using SQL? My database is DB2
TableFoo
-------
Id Name
1 Apples
1 Tomatoes
1 Potatoes
2 Banana
2 Peach
I want something like
ID FruitsAvailable
-------------------------
1 Apples, Tomatoes, Potatoes
try this
HERE DEMO SQLFIDDLE
EDIT: in db2 you need to create function and then call it
and then call it here
Use this query: