Hi, try this:
SELECT title, LISTAGG('name', ', ') WITHIN GROUP (ORDER BY name) AS joined_name
FROM movies GROUP BY title;
It will do the trick for You assuming, the name of the table is "movies" (change to whatever)
I think you need 2 separate queries & programmatic loops:
1st query to get your list of distinct Titles, then you loop on these results & for each you run 2nd query to get the genres for that specific Title, then you can loop on genres & do what you need with your title & attached genres, then same for next title, etc.
2 very simple queries, 2 nested loops, you're done.
Tell me if that makes sense.