query-fb0c76306cbf11ab6b36f6da5676f9bd

rq turtle/ttl

Script #2 SELECT ?game (GROUP_CONCAT(DISTINCT ?dateYear ; separator = ", ") AS ?dateYears) WHERE { # types of item {?game wdt:P136 wd:Q744038} # regular RPGs UNION {?game wdt:P136 wd:Q1529437} # tactical RPGs UNION {?game wdt:P136 wd:Q1422746} # action RPGs UNION {?game wdt:P136 wd:Q1143132} # roguelikes #?game wdt:P136/wdt:P279* wd:Q744038. # any class or subclass of role-playing video game, including MMORPGs ?game wdt:P31 wd:Q7889. # instance of video game

    OPTIONAL {
      ?game p:P577 ?statement .
      ?statement ps:P577 ?date .
      OPTIONAL {
        ?statement pq:P291 ?place .
        OPTIONAL { ?place rdfs:label ?place_label FILTER( LANG( ?place_label ) = 'en' ) } .
      } .
      BIND( CONCAT( STR( YEAR( ?date ) ), ' (', COALESCE( ?place_label, '???' ), ')' ) AS ?dateYear ) .
    } .
  }
GROUP BY ?game
ORDER BY ?dateYears

Use at

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
# Script #2
SELECT ?game
      (GROUP_CONCAT(DISTINCT     ?dateYear ; separator = ", ") AS     ?dateYears)
      WHERE {
        # types of item
              {?game wdt:P136 wd:Q744038}   # regular RPGs
        UNION {?game wdt:P136 wd:Q1529437}  # tactical RPGs
        UNION {?game wdt:P136 wd:Q1422746}  # action RPGs
        UNION {?game wdt:P136 wd:Q1143132}  # roguelikes
        #?game wdt:P136/wdt:P279* wd:Q744038.   # any class or subclass of role-playing video game, including MMORPGs
        ?game wdt:P31 wd:Q7889.             # instance of video game

        OPTIONAL {
          ?game p:P577 ?statement .
          ?statement ps:P577 ?date .
          OPTIONAL {
            ?statement pq:P291 ?place .
            OPTIONAL { ?place rdfs:label ?place_label FILTER( LANG( ?place_label ) = 'en' ) } .
          } .
          BIND( CONCAT( STR( YEAR( ?date ) ), ' (', COALESCE( ?place_label, '???' ), ')' ) AS ?dateYear ) .
        } .
      }
    GROUP BY ?game
    ORDER BY ?dateYears

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?date") v7("?dateYear"):::projected v8("?dateYears") v2("?game"):::projected v6("?place") v5("?place_label") v3("?statement") c4(["wd:Q1422746"]):::iri c3(["wd:Q1529437"]):::iri c2(["wd:Q744038"]):::iri c7(["wd:Q7889"]):::iri c5(["wd:Q1143132"]):::iri 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; v2 --"p:direct/P136"--> c5 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P136"--> c4 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P136"--> c3 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P136"--> c2 end union0r <== or ==> union0l end v2 --"p:direct/P31"--> c7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:P577".-> v3 v3 --"p:statement/P577"--> v4 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P291".-> v6 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v5 end end bind0[/"concat(str(year-from-dateTime(?date)),' (',?place_label'???',')')"/] v4 --o bind0 v5 --o bind0 bind0 --as--o v7 end bind2[/"?dateYear"/] v7 --o bind2 bind2 --as--o v8