- question: All genres with their frequency and average rating
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?genre (COUNT(?movie) AS ?count) (AVG(?rating) AS ?avg_rating) WHERE {
      ?movie imdb:genre ?genre .
      ?movie imdb:averageRating ?rating .
    }
    GROUP BY ?genre
    ORDER BY DESC(?count)
- question: The 10 persons with most votes on average over at least 3 titles
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?person WHERE {
      {
        SELECT ?person (COUNT(?title) AS ?count) (AVG(?numvotes) AS ?avg_votes) WHERE {
          ?person imdb:knownForTitle ?title .
          ?title imdb:numVotes ?numvotes .
        }
        GROUP BY ?person
      }
      FILTER (?count >= 3)
    }
    ORDER BY DESC(?avg_votes)
    LIMIT 10
- question: People who are known for at least 3 titles with more than 1 M votes
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?person WHERE {
      {
        SELECT ?person (COUNT(?title) AS ?count) WHERE {
          ?person imdb:knownForTitle ?title .
          ?title imdb:numVotes ?numvotes .
          FILTER (?numvotes > 1000000)
        }
        GROUP BY ?person
        HAVING (?count >= 3)
      }
    }
- question: 100 oldest lead directors at the time of a movie (not series) with >= 100k votes
  sparql: |
    PREFIX imdb_principal: <https://www.imdb.com/principal/>
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?person WHERE {
      ?movie imdb:type "movie" .
      ?movie imdb_principal:director ?person .
      ?person imdb:birthYear ?birthYear .
      ?movie imdb:startYear ?startYear .
      ?movie imdb:numVotes ?num_votes .
      FILTER (?num_votes >= 100000)
      BIND (?startYear - ?birthYear AS ?age)
    }
    ORDER BY DESC(?age)
    LIMIT 100
- question: Series with more than 1 M votes with most episodes
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?series WHERE {
      {
        SELECT ?series (COUNT(?episode) AS ?num_episodes) WHERE {
          ?episode imdb:parentTitle ?series .
        }
        GROUP BY ?series
      }
      ?series imdb:numVotes ?num_votes .
      FILTER (?num_votes >= 1000000)
    }
    ORDER BY DESC(?num_episodes)
- question: 100 oldest main actors at the time of a movie (not series) with >= 100k votes
  sparql: |
    PREFIX imdb_principal: <https://www.imdb.com/principal/>
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?person WHERE {
      ?movie imdb:type "movie" .
      ?movie imdb_principal:actor ?person .
      ?person imdb:birthYear ?birth_year .
      ?movie imdb:startYear ?start_year .
      ?movie imdb:numVotes ?num_votes .
      FILTER (?num_votes >= 100000)
      BIND (?start_year - ?birth_year AS ?age)
    }
    ORDER BY DESC(?age)
    LIMIT 100
- question: Highest rated movie (not series) with >= 100k votes per lead director, top 10 overall
  sparql: |
    PREFIX imdb_principal: <https://www.imdb.com/principal/>
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?movie WHERE {
      ?movie imdb_principal:director ?director .
      ?movie imdb:averageRating ?rating .
      ?movie imdb:numVotes ?votes .
      ?movie imdb:type "movie" .
      FILTER (?votes >= 100000)
      {
        SELECT ?director (MAX(?ratingSub) AS ?maxRatingSub) WHERE {
          ?movieSub imdb_principal:director ?director .
          ?movieSub imdb:averageRating ?ratingSub .
          ?movieSub imdb:numVotes ?votesSub .
          ?movieSub imdb:type "movie" .
          FILTER (?votesSub >= 100000)
        }
        GROUP BY ?director
      }
      FILTER (?rating = ?maxRatingSub)
    }
    GROUP BY ?director ?movie
    ORDER BY DESC(?maxRating)
    LIMIT 10
- question: Youngest lead director of a movie with over 1M votes
  sparql: |
    PREFIX imdb_principal: <https://www.imdb.com/principal/>
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?director WHERE {
      ?movie imdb:numVotes ?numVotes .
      FILTER (?numVotes > 1000000) .
      ?movie imdb_principal:director ?director .
      ?director imdb:birthYear ?birthYear .
      ?movie imdb:startYear ?startYear .
      BIND(?startYear - ?birthYear AS ?age) 
    }
    ORDER BY ?age
    LIMIT 1
- question: Actors who are known for at least three adult titles but also for one non-adult title with >= 100k votes
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?person {
      {
        SELECT ?person (COUNT(?title) AS ?count) WHERE {
          ?person imdb:knownForTitle ?title .
          ?title imdb:isAdult true .
        }
        GROUP BY ?person
      }
      FILTER (?count >= 3)
      ?person imdb:knownForTitle ?title .
      ?title imdb:isAdult false .
      ?title imdb:numVotes ?num_votes .
      FILTER (?num_votes >= 100000)
    }
    ORDER BY DESC(?num_votes)
- question: Top 10 lead actor-director pairs with at least 5 collaborations in movies (not series) with at least 100k votes
  sparql: |
    PREFIX imdb_principal: <https://www.imdb.com/principal/>
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?actor ?director (COUNT(?movie) AS ?collaboration_count) WHERE {
      ?movie imdb:type "movie" .
      ?movie imdb:numVotes ?votes .
      FILTER (?votes >= 100000) .
      ?movie imdb_principal:actor ?actor .
      ?movie imdb_principal:director ?director .
    }
    GROUP BY ?actor ?director
    HAVING (?collaboration_count >= 5)
    ORDER BY DESC(?collaboration_count)
- question: Average rating of Sci-Fi movies (not series) by decade, for movies with over 10k votes
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    SELECT ?decade (AVG(?rating) AS ?avg_rating) WHERE {
      ?movie imdb:type "movie" .
      ?movie imdb:genre "Sci-Fi" .
      ?movie imdb:averageRating ?rating .
      ?movie imdb:numVotes ?votes .
      ?movie imdb:startYear ?year .
      FILTER(?votes > 10000)
      BIND (FLOOR(?year / 10) * 10 AS ?decade)
    }
    GROUP BY ?decade
    ORDER BY ?decade
- question: People who were a principal actor and a principal director in different titles, both with over 100k votes
  sparql: |
    PREFIX imdb_principal: <https://www.imdb.com/principal/>
    PREFIX imdb: <https://www.imdb.com/>
    SELECT DISTINCT ?person WHERE {
      ?title_acted imdb_principal:actor ?person .
      ?title_acted imdb:numVotes ?votes_acted .
      FILTER(?votes_acted > 100000) .

      ?title_directed imdb_principal:director ?person .
      ?title_directed imdb:numVotes ?votes_directed .
      FILTER(?votes_directed > 100000) .

      FILTER(?title_acted != ?title_directed)
    }
- question: Top 10 series by average episode rating, for series with at least 20 episodes with min 10k votes each
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?series WHERE {
      {
        SELECT ?series (AVG(?rating) AS ?ep_rating) (COUNT(?episode) AS ?ep_count) WHERE {
          ?episode imdb:parentTitle ?series .
          ?series imdb:type "tvSeries" .
          ?episode imdb:averageRating ?rating .
          ?episode imdb:numVotes ?numvotes .
          FILTER (?numvotes >= 10000)
        }
        GROUP BY ?series
      }
      FILTER (?ep_count >= 20)
    }
    ORDER BY DESC(?ep_rating)
    LIMIT 10
- question: Top 10 series with over 100k votes and the largest runtime difference between episodes
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    SELECT ?series WHERE {
      ?series imdb:numVotes ?votes .
      FILTER (?votes > 100000) .
      ?series imdb:type "tvSeries" .
      {
        SELECT ?series (MIN(?runtime) AS ?min_runtime) (MAX(?runtime) AS ?max_runtime) WHERE {
          ?episode imdb:parentTitle ?series .
          ?episode imdb:runtimeMinutes ?runtime .
        }
        GROUP BY ?series
        HAVING (COUNT(?episode) > 1)
      }
      BIND (?max_runtime - ?min_runtime AS ?runtime_difference)
    }
    ORDER BY DESC(?runtime_difference)
    LIMIT 10
- question: Top 3 episodes of the last Breaking Bad season
  sparql: |
    PREFIX imdb: <https://www.imdb.com/>
    PREFIX imdb_title: <https://www.imdb.com/title/>
    SELECT ?episode WHERE {
      ?episode imdb:parentTitle imdb_title:tt0903747 .
      ?episode imdb:averageRating ?rating .
      ?episode imdb:seasonNumber 5
    }
    ORDER BY DESC(?rating)
    LIMIT 3
