query-be84e661f7d0eee79909cab221610624

rq turtle/ttl

Video game series with the longest time time gap between a game and its direct sequel

(as games can have more than one publication date [because re-releases], we only take the earliest one [using MIN])

SELECT ?series ?seriesLabel ?years ?interval ?game ?gameLabel ?original_date_game ?sequel ?sequelLabel ?original_date_sequel WHERE { { SELECT ?game ?gameLabel (MIN(?game_date) AS ?original_date_game) ?sequel ?sequelLabel (MIN(?sequel_date) AS ?original_date_sequel) ?series ?seriesLabel WHERE { ?game (wdt:P31/(wdt:P279*)) wd:Q7889; # All video games... wdt:P577 ?game_date. # with their publication date(s)... { ?game p:P179 ?series_statement. # (Unpacking the series statement) ?series_statement ps:P179 ?series; # ...in a series... pq:P156 ?sequel. # ...with a sequel... } UNION { # ...or... ?game wdt:P156 ?sequel. # ...with a sequel... OPTIONAL { ?game wdt:P179 ?series # ...maybe with a series } } ?sequel wdt:P577 ?sequel_date. # with its own publication date(s) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?game ?gameLabel ?sequel ?sequelLabel ?series ?seriesLabel } BIND(?original_date_sequel - ?original_date_game AS ?interval) # Calculating the time gap between the original releases, in days... BIND(ROUND(?interval / 365 ) AS ?years) # ...and converting to years, for convenience... FILTER(?interval > 0 ) # Only keeping sequels published after (filtering out some bad data) } ORDER BY DESC (?interval) # Longest time gaps first

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Video game series with the longest time time gap between a game and its direct sequel
# (as games can have more than one publication date [because re-releases], we only take the earliest one [using MIN])
SELECT ?series ?seriesLabel ?years ?interval ?game ?gameLabel ?original_date_game ?sequel ?sequelLabel ?original_date_sequel WHERE {
  {
    SELECT ?game ?gameLabel (MIN(?game_date) AS ?original_date_game) ?sequel ?sequelLabel (MIN(?sequel_date) AS ?original_date_sequel) ?series ?seriesLabel WHERE {
      ?game (wdt:P31/(wdt:P279*)) wd:Q7889; # All video games...
        wdt:P577 ?game_date.                # with their publication date(s)...
      {
        ?game p:P179 ?series_statement.     # (Unpacking the series statement)
        ?series_statement ps:P179 ?series;  #   ...in a series...
          pq:P156 ?sequel.                  #   ...with a sequel...
      } UNION {                             # ...or...
        ?game wdt:P156 ?sequel.             #   ...with a sequel...
        OPTIONAL {
          ?game wdt:P179 ?series            # ...maybe with a series
        }
      }
      ?sequel wdt:P577 ?sequel_date.        # with its own publication date(s)
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    GROUP BY ?game ?gameLabel ?sequel ?sequelLabel ?series ?seriesLabel
  }
  BIND(?original_date_sequel - ?original_date_game AS ?interval)  # Calculating the time gap between the original releases, in days...
  BIND(ROUND(?interval / 365 ) AS ?years)                         # ...and converting to years, for convenience...
  FILTER(?interval > 0 )                                          # Only keeping sequels published after (filtering out some bad data)
}
ORDER BY DESC (?interval)                                         # Longest time gaps first

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?game"):::projected v3("?game_date") v10("?interval"):::projected v8("?original_date_game"):::projected v9("?original_date_sequel"):::projected v6("?sequel"):::projected v7("?sequel_date") v5("?series"):::projected v4("?series_statement") v10("?years"):::projected a1((" ")) c12(["bd:serviceParam"]):::iri c4(["wd:Q7889"]):::iri c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?interval > '0^^xsd:integer'"]] f0 --> v10 v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 v2 --"p:direct/P577"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P156"--> v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P179".-> v5 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:P179"--> v4 v4 --"p:statement/P179"--> v5 v4 --"p:qualifier/P156"--> v6 end union0r <== or ==> union0l end v6 --"p:direct/P577"--> v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end bind3[/"min(?game_date)"/] v3 --o bind3 bind3 --as--o v8 bind4[/"min(?sequel_date)"/] v7 --o bind4 bind4 --as--o v9 bind5[/"?original_date_sequel - ?original_date_game"/] v9 --o bind5 v8 --o bind5 bind5 --as--o v10 bind6[/"numeric-round(?interval / '365^^xsd:integer')"/] v10 --o bind6 bind6 --as--o v10