Skip to content
Advertisement

How to join SQL column elements together?

I have an SQL table with the column named expenses like this

enter image description here

I want to write a query to return all the elements of this column separated by a comma. For the above example output should be:-

How can I do this?

Advertisement

Answer

You can use the group_concat aggregate function:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement