I am trying to show the details of movie, with number of roles and the number of genres it is classified as. (Family, Fantasy).
I expected the result to come out as:
movie_id title genre count(movie_role) count(genre)
675 harry potter a family 3 2
675 harry potter a fantasy 3 2
767 harry potter b family 3 1
My code:
SELECT movie_id, title, count(movie_role), genre
from moviesInGenre
group by movie_id, title, genre;
Because harry potter a is classified as genre family and fantasy,
so I want it to have a column counting the genres it is classified as. (2). And harry potter b is classified as family only so should have a count of 1.
Sample data:
movie_id title movie_role actor_id aname genre
675 harry potter a Harry 10993 Jarney Family
675 harry potter a Nana 10232 Sam Fantasy
767 harry potter b John 10911 Cart Family
Thanks in advance!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…