query-b3eb4ec30246a8dd53e0a49ffb7a4606

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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 bd: <http://www.bigdata.com/rdf#>
SELECT (COALESCE(?parent, ?project) AS ?qid) (COALESCE(?parentLabel, ?projectLabel) AS ?name) (COALESCE(?inception, ?parentInception) AS ?inception) ?editions {
  {
    SELECT ?project (COUNT(?edition) AS ?editions) {
      ?project (wdt:P31|wdt:P279) wd:Q33120876.
      OPTIONAL { ?edition wdt:P31 ?project. }
    } GROUP BY ?project
  }
  OPTIONAL { ?project wdt:P571 ?inception. }
  OPTIONAL {
    ?project wdt:P629 ?parent.
    OPTIONAL { ?parent wdt:P571 ?parentInception. }
  }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    # Since we use the labels in the COALESCE functions we have to use the label service in manual mode
    # see https://en.wikibooks.org/wiki/SPARQL/SERVICE_-_Label#Manual_Label_SERVICE
    ?parent rdfs:label ?parentLabel.
    ?project rdfs:label ?projectLabel.
  }
} ORDER BY ?inception

Query found at