title: Sakila db SQL find total combined film length of Sci-Fi films for every actor
body: <p>For reference I am working on the Sakila rental DVD database outlined <a href="http://www.ntu.edu.sg/home/ehchua/programming/sql/SampleDatabases.html" rel="nofollow">here</a> (#2): </p>
  
  <p>Basically, I am trying to make a query to list every actor and their total run time of sci-fi films they've been in. They should be in the table with a total run time of NULL or 0 if they've never been in a sci-fi film.</p>
  
  <p>I was able to figure out how to get a list of actors who HAVE been in sci-fi but I'm not sure where I'm going wrong to exclude any actors who haven't been in a sci-fi film.</p>
  
  <pre><code>SELECT act.first_name, act.last_name, SUM(fm.length)
  FROM film fm
  INNER JOIN film_actor fa ON fa.film_id = fm.film_id
  INNER JOIN actor act ON fa.actor_id = act.actor_id
  INNER JOIN film_category fc ON fm.film_id = fc.film_id
  INNER JOIN category cat ON fc.category_id = cat.category_id AND cat.name = 'Sci-Fi'
  GROUP BY act.first_name, act.last_name
  ORDER BY act.last_name ASC
  </code></pre>
  
  <p>I have tried changing to LEFT JOINs for the two rows that get the actors (the first two joins) as I thought that might solve the issue of actors without the film not being included but I ended up with the same results.</p>