SQL question/problem | SoloLearn: Learn to code for FREE!


SQL question/problem

Hi, Its kind of hard to explain so i'll attatch an image. I'am basically trying to group the genres collumn somehow. Image: https://vkdev.be/Aantekening%202018-12-22%20185016.jpg

12/22/2018 5:57:12 PM

Arne Van Kerckvoorde

5 Answers

New Answer


Hi sneeze I want the result to be like: Movie | genre, genre Instead of Movie genre Movie genre So the same movie does not repeat in the results.


You can use this query with distinct to only show non repetative movies. SELECT DISTINCT Movie FROM Title; 


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)


Hey Skizzles 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.


I do not understand your question. Do you want to assign multiple categories to a film or sort films bases upon categories