-2

I’m trying to list the actors (male/female) that have starred in 10 or more different film genres I have a table called actors which contains three columns:actorID,name,gender and another table called movies which contains movieID,title,year, last table is movies_actor it contains movieID,actorID,as_charachter,leading

THeHac101
  • 7
  • 4

2 Answers2

0

To get the count of movie for each actor You need the actor_name and the movieid which are in two different table. First you can take the actorid and the count of movieid from movies_actors table and the join it with the actor_table to get the name of the actor. You have to apply a condition in select statement >9 as you want the actor name who has done 10 or more than 10 movies. For genres you can try once from your end if you get any error then you can ask question.

     select name from  
       (select s.*,a.name from 
          (select actorid, count(distinct movieid)no_of_movies from movies_actors group by  actorid)s 
      join 
      actor_table a
      on a.actorid=s.actorid
       )b
where no_of_movies>9

But It will be good for you if you try first from your end and then you can ask questions here like if you stuck or if you get any error or not get the desired output. In this way you can learn more.

Jaishree Rout
  • 382
  • 5
  • 17
0

Check whether below query give your expected result.

SELECT
  a.name,
  a.gender,
  COUNT(ac.movieid) NoOf_Movies
FROM
  actors a
  INNER JOIN actor_movie am ON a.id = am.actorID
GROUP BY
  a.name,
  a.gender
HAVING
  COUNT(ac.movieid) > 9
ORDER BY
  am.movieID DESC
Tharuka Madumal
  • 201
  • 2
  • 5