Issue
I need function, that returns list of strings.
I have data in table like this:
Id MyString
------------------------
1 First
2 Second
3 Third
4 Fourth
I need function like this (something like this works in oracle):
select LISTAGG(MyString, ', ') as myList where id < 4
That returns something like this:
myList
------------------------
First, Second, Third
Any ideas?
Solution
You’re looking for GROUP_CONCAT()
Try this:
select group_concat(MyString separator ', ') as myList from table
where id < 4
Of course, you can group by
the results.
Answered By – Mosty Mostacho
Answer Checked By – Mildred Charles (BugsFixing Admin)