query-236e477c2b251ddef70e5e1ea5593c92
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))
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# movie production companies by number of future movies
SELECT ?company ?companyLabel (COUNT(?movie) AS ?count) (GROUP_CONCAT(?movieLabel; separator = "; ") AS ?movies) WHERE {
{
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())
}
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))
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?_anon_42b5416610844a34809f33a099ae9de1146864")
v4("?company"):::projected
v5("?companyLabel"):::projected
v8("?count")
v3("?movie"):::projected
v6("?movieLabel"):::projected
v8("?movies")
v5("?publicationDate")
a2((" "))
a1((" "))
c8(["bd:serviceParam"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c4(["wd:Q11424"]):::iri
f0[["?count > '1^^xsd:integer'"]]
f0 --> v8
f1[["?publicationDate > NOW()"]]
f1 --> v5
v3 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c4
v3 --"wdt:P272"--> v4
v3 --"wdt:P577"--> v5
bind3[/"min(?publicationDate)"/]
v5 --o bind3
bind3 --as--o v5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
v4 --"rdfs:label"--> v5
v3 --"rdfs:label"--> v6
end
bind7[/"max(?publicationDate)"/]
v5 --o bind7
bind7 --as--o v7
bind8[/"count(?movie)"/]
v3 --o bind8
bind8 --as--o v8
bind9[/"?movieLabel"/]
v6 --o bind9
bind9 --as--o v8