query-422b33389c1788922e98ac6a9f400924

rq turtle/ttl

SPARQL query

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#>
SELECT ?id
  ?item ?itemLabel (?itemLabel as ?name)
  ?group ?groupLabel (?groupLabel as ?faction)
  ?districtAreaLabel (?districtAreaLabel as ?area)
  ?term
  (STRBEFORE(STR(?start), "T" ) AS ?start_date)
  (STRBEFORE(STR(?end), "T" ) AS ?end_date)
WHERE 
{
  ?item p:P39 ?statement .
  ?statement ps:P39/wdt:P279* wd:Q3044918 .
  ?statement pq:P2937 ?termStatement .
  ?termStatement p:P31/pq:P1545 ?term .
  OPTIONAL { ?statement pq:P580  ?start }
  OPTIONAL { ?statement pq:P582  ?end }
  OPTIONAL { ?statement pq:P768  ?district .
    ?district wdt:P131 ?districtArea
  }
  OPTIONAL { ?statement pq:P4100 ?group }
  OPTIONAL { ?item wdt:P1045 ?id }
  FILTER (?term = "14")
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,en". }
}
ORDER BY ?start_date ?end_date

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v15("?area") v9("?district") v10("?districtArea") v8("?end"):::projected v16("?end_date") v14("?faction") v11("?group"):::projected v12("?id"):::projected v4("?item"):::projected v13("?name") v7("?start"):::projected v16("?start_date") v5("?statement") v3("?term"):::projected v6("?termStatement") a1((" ")) a2((" ")) c5(["wd:Q3044918"]):::iri c18(["#91;AUTO_LANGUAGE#93;,fr,en"]):::literal c16(["bd:serviceParam"]):::iri f0[["?term = '14'"]] f0 --> v3 v4 --"p:P39"--> v5 v5 --"p:statement/P39"--> a1 a1 --"p:direct/P279"--> c5 v5 --"p:qualifier/P2937"--> v6 v6 --"p:P31"--> a2 a2 --"p:qualifier/P1545"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P580".-> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P582".-> v8 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P768".-> v9 v9 --"p:direct/P131"--> v10 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P4100".-> v11 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P1045".-> v12 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end bind1[/"?itemLabel"/] null --o bind1 bind1 --as--o v13 bind2[/"?groupLabel"/] null --o bind2 bind2 --as--o v14 bind3[/"?districtAreaLabel"/] null --o bind3 bind3 --as--o v15 bind4[/"substring-before(str(?start),'T')"/] v7 --o bind4 bind4 --as--o v16 bind5[/"substring-before(str(?end),'T')"/] v8 --o bind5 bind5 --as--o v16