query-41e0b41ed4159702b2950c46f378befc

rq turtle/ttl

find films with cost between 50 and 100 millions USD and

country of origin as USA or Canada or Australia or New Zealand or a European country

SELECT DISTINCT ?film ?filmLabel ?cost_amount WHERE { # instance of (P31) or instance of subclass of (P279) film (Q11424) ?film wdt:P31/wdt:P279 wd:Q11424; # define cost (P2130) as ?cost p:P2130/psv:P2130 ?cost. # divide ?cost into amount and unit ?cost wikibase:quantityAmount ?cost_amount; wikibase:quantityUnit ?cost_unit. # cost's amount >= 50 millions, AND amount <= 100 millions, AND unit is USD (Q4917) FILTER(?cost_amount>=50000000 && ?cost_amount<=100000000 && ?cost_unit=wd:Q4917) # film's country of origin (P495) is United States (Q30) {?film wdt:P495 wd:Q30} # OR country of origin (P495) is Canada (Q16) UNION {?film wdt:P495 wd:Q16} # OR country of origin (P495) is Australia (Q408) UNION {?film wdt:P495 wd:Q408} # OR country of origin (P495) is New Zealand (Q664) UNION {?film wdt:P495 wd:Q664} # OR country of origin (P495) is a European country (?EC) UNION {?film wdt:P495 ?EC. # ?EC is instance of (P31) or instance of subclass of (P279) ?x, and ?EC wdt:P31/wdt:P279 ?x; # ?EC's continent (P30) is Europe (Q46) wdt:P30 wd:Q46. # define ?x as country (Q6256) and historical country (Q3024240) VALUES ?x {wd:Q6256 wd:Q3024240} } # show label in auto language as default, and English when no default label exists SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# find films with cost between 50 and 100 millions USD and
# country of origin as USA or Canada or Australia or New Zealand or a European country
SELECT DISTINCT ?film ?filmLabel ?cost_amount
WHERE {
  # instance of (P31) or instance of subclass of (P279) film (Q11424)
  ?film wdt:P31/wdt:P279* wd:Q11424;
        # define cost (P2130) as ?cost
        p:P2130/psv:P2130 ?cost.
  # divide ?cost into amount and unit
  ?cost wikibase:quantityAmount ?cost_amount;
        wikibase:quantityUnit ?cost_unit.
  # cost's amount >= 50 millions, AND amount <= 100 millions, AND unit is USD (Q4917)
  FILTER(?cost_amount>=50000000 && ?cost_amount<=100000000 && ?cost_unit=wd:Q4917)
  # film's country of origin (P495) is United States (Q30)
  {?film wdt:P495 wd:Q30}
  # OR country of origin (P495) is Canada (Q16)
  UNION {?film wdt:P495 wd:Q16}
  # OR country of origin (P495) is Australia (Q408)
  UNION {?film wdt:P495 wd:Q408}
  # OR country of origin (P495) is New Zealand (Q664)
  UNION {?film wdt:P495 wd:Q664}
  # OR country of origin (P495) is a European country (?EC)
  UNION {?film wdt:P495 ?EC.
         # ?EC is instance of (P31) or instance of subclass of (P279) ?x, and
         ?EC wdt:P31/wdt:P279* ?x;
             # ?EC's continent (P30) is Europe (Q46)
             wdt:P30 wd:Q46.
         # define ?x as country (Q6256) and historical country (Q3024240)
         VALUES ?x {wd:Q6256 wd:Q3024240} }
  # show label in auto language as default, and English when no default label exists
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?EC") v4("?cost") v1("?cost_amount"):::projected v2("?cost_unit") v3("?film"):::projected v7("?x") a1((" ")) a2((" ")) a3((" ")) c12(["wd:Q30"]):::iri c14(["wd:Q408"]):::iri c17(["wd:Q46"]):::iri c13(["wd:Q16"]):::iri c15(["wd:Q664"]):::iri c19(["bd:serviceParam"]):::iri c21(["#91;AUTO_LANGUAGE#93;,en"]):::literal c6(["wd:Q11424"]):::iri f0[["?cost_amount >= '50000000^^xsd:integer'?cost_amount <= '100000000^^xsd:integer'?cost_unit = 'wd:Q4917'"]] f0 --> v1 f0 --> v2 v3 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c6 v3 --"p:P2130"--> a2 a2 --"p:statement/value/P2130"--> v4 v4 --"wikibase:quantityAmount"--> v1 v4 --"wikibase:quantityUnit"--> v2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P495"--> v5 v5 --"p:direct/P31"--> a3 a3 --"p:direct/P279"--> v7 v5 --"p:direct/P30"--> c17 bind1[/VALUES ?x/] bind1-->v7 bind10(["wd:Q6256"]) bind10 --> bind1 bind11(["wd:Q3024240"]) bind11 --> bind1 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P495"--> c15 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P495"--> c14 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P495"--> c13 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P495"--> c12 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c19 --"wikibase:language"--> c21 end