query-097edc25ecc890da05e3d94614b35d0d
TODO
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?prodco ?prodcoLabel (SUM(?boxOffice - ?cost) as ?totalNetProfit)
WHERE
{
# Find all production companies who have not produced an films in USA
{ # Find all production compnaies
SELECT ?prodco
WHERE {
?art wdt:P272 ?prodco. # art produced by production companies
?art wdt:P31 wd:Q11424. # ensure that the art produced is an instance of film
}
}
MINUS
{ # Find production companies that have produced at least 1 film with origin USA
SELECT ?USAOriginprodco
WHERE
{
?art wdt:P272 ?USAOriginprodco. # get producers of the art
?art wdt:P31 wd:Q11424. # ensure that the art produced is an instance of film
?art wdt:P495 wd:Q30. # country of origin of the art is USA
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
# Now caluclate the net profits of the production companies
?art wdt:P272 ?prodco. # art produced by production companies
?art wdt:P31 wd:Q11424. # ensure that the art produced is an instance of film
?art wdt:P2142 ?boxOffice. # get the box office earnings for the film
?art wdt:P2130 ?cost. # Find the cost of each art
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?prodco ?prodcoLabel
ORDER BY desc(?totalNetProfit)
LIMIT 20
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?USAOriginprodco")
v2("?art")
v5("?boxOffice"):::projected
v6("?cost"):::projected
v3("?prodco"):::projected
v7("?totalNetProfit")
c7(["bd:serviceParam"]):::iri
c5(["wd:Q30"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c3(["wd:Q11424"]):::iri
v2 --"wdt:P272"--> v3
v2 --"wdt:P31"--> c3
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v2 --"wdt:P272"--> v4
v2 --"wdt:P31"--> c3
v2 --"wdt:P495"--> c5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end
end
v2 --"wdt:P272"--> v3
v2 --"wdt:P31"--> c3
v2 --"wdt:P2142"--> v5
v2 --"wdt:P2130"--> v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end
bind2[/"sum(?boxOffice - ?cost)"/]
v5 --o bind2
v6 --o bind2
bind2 --as--o v7