+ 13

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

22nd Dec 2018, 5:57 PM
Arne Van Kerckvoorde
Arne Van Kerckvoorde - avatar
5 Answers
+ 6
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.
23rd Dec 2018, 6:53 AM
Arne Van Kerckvoorde
Arne Van Kerckvoorde - avatar
+ 5
You can use this query with distinct to only show non repetative movies. SELECT DISTINCT Movie FROM Title; 
23rd Dec 2018, 9:05 AM
MsJ
MsJ - avatar
+ 3
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)
23rd Dec 2018, 6:07 PM
Jakub DubaƄski
Jakub DubaƄski - avatar
+ 1
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.
23rd Dec 2018, 11:25 AM
Tom BWDEV đŸ‡ș🇩
Tom BWDEV đŸ‡ș🇩 - avatar
0
I do not understand your question. Do you want to assign multiple categories to a film or sort films bases upon categories
22nd Dec 2018, 7:14 PM
sneeze
sneeze - avatar