I have an SQL table with the column named expenses like this
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:-
hotel,taxi,food,movie
How can I do this?
Advertisement
Answer
You can use the group_concat aggregate function:
SELECT GROUP_CONCAT(expenses) FROM my_table