User:TweetsFactsAndQueries/Queries/movie production companies by number of future movies

Originally posted on Twitter.

# movie production companies by number of future movies
SELECT ?company ?companyLabel (COUNT(?movie) AS ?count) (GROUP_CONCAT(?movieLabel; separator = "; ") AS ?movies) WITH {
  SELECT ?movie ?company (MIN(?publicationDate) AS ?publicationDate) WHERE {
    ?movie wdt:P31/wdt:P279* wd:Q11424;
           wdt:P272 ?company;
           wdt:P577 ?publicationDate.
  }
  GROUP BY ?movie ?company
  HAVING(?publicationDate > NOW())
} AS %futureMovies WHERE {
  INCLUDE %futureMovies.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?company rdfs:label ?companyLabel.
    ?movie rdfs:label ?movieLabel.
  }
}
GROUP BY ?company ?companyLabel
HAVING(?count > 1)
ORDER BY DESC(?count) DESC(MAX(?publicationDate))
Try it!