Skip to content

concatenating one to many values to one line separated by commas in sql join

I have a join which shares a one to many relationship to one table. I would to in stead of returning this value:

I want to return one line like this:

Here is the sql i am running now:

How would I end up with the correct output?

Advertisement

Answer

You need to use a function for that. See LISTAGG

EDIT:

Last time I used Oracle you could use LISTAGG using group by. I just looked at the docs and it doesn’t mention it anymore. Here is the way if above does not work:

Note: I’m just showing how to use the function. Did not look at your query at all. Adding this note because your result data does not match the number of columns on your SQL

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