query-240669c8657be01733f9c78800caecee

rq turtle/ttl

Folding values in a query Hi there, this query almost does what I want it to.

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
SELECT * WHERE {
  {
    SELECT ?sen ?senLabel ?replaces ?replacedBy ?start ?end WHERE {
      ?sen p:P39 ?stmt.
      ?stmt ps:P39 wd:Q4416090;
        pq:P2937 ?term.
      {
        ?stmt pq:P1365 ?replaces;
          pq:P580 ?start.
      }
      UNION
      {
        ?stmt pq:P1365 ?replacedBy;
          pq:P582 ?end.
      }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    ORDER BY (?sen) (?end)
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?end"):::projected v7("?replacedBy"):::projected v5("?replaces"):::projected v1("?sen"):::projected v6("?start"):::projected v3("?stmt") v4("?term") c9(["bd:serviceParam"]):::iri c3(["wd:Q4416090"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal v1 --"p:P39"--> v3 v3 --"p:statement/P39"--> c3 v3 --"p:qualifier/P2937"--> v4 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"p:qualifier/P1365"--> v7 v3 --"p:qualifier/P582"--> v2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:qualifier/P1365"--> v5 v3 --"p:qualifier/P580"--> v6 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end