query-4f314824da41f68f916327c841eee98c

rq turtle/ttl

TEMPLATE={"template":"Games developed and published by ?studio","variables":{"?studio":{"query":" SELECT ?id WHERE { ?id wdt:P31 wd:Q210167 . }"} } } SELECT DISTINCT ?item ?itemLabel ?developer ?developerLabel ?publisher ?publisherLabel ?year WHERE { BIND(wd:Q55587315 AS ?studio) { ?item wdt:P178 ?studio. } UNION { ?item wdt:P123 ?studio. } OPTIONAL { ?item wdt:P178 ?developer. } OPTIONAL { ?item wdt:P123 ?publisher. } OPTIONAL { ?item wdt:P577 ?date. BIND(YEAR(?date) AS ?year) } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY ?year

Use at

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#>
#TEMPLATE={"template":"Games developed and published by ?studio","variables":{"?studio":{"query":" SELECT ?id WHERE { ?id wdt:P31 wd:Q210167 . }"} } }
SELECT DISTINCT ?item ?itemLabel ?developer ?developerLabel ?publisher ?publisherLabel ?year WHERE {
  BIND(wd:Q55587315 AS ?studio)
  { ?item wdt:P178 ?studio. }
  UNION
  { ?item wdt:P123 ?studio. }
  OPTIONAL { ?item wdt:P178 ?developer. }
  OPTIONAL { ?item wdt:P123 ?publisher. }
  OPTIONAL {
    ?item wdt:P577 ?date.
    BIND(YEAR(?date) AS ?year)
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?year

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?date") v4("?developer"):::projected v3("?item"):::projected v5("?publisher"):::projected v2("?studio") v7("?year"):::projected c5(["bd:serviceParam"]):::iri c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/"'wd:Q55587315'"/] bind0 --as--o v2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P123"--> v2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P178"--> v2 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P178".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P123".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P577".-> v6 bind1[/"year-from-dateTime(?date)"/] v6 --o bind1 bind1 --as--o v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end