query-376d87657892736394b05ba57370b17e

rq turtle/ttl

SPARQL query

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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 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 DISTINCT ?name (SUBSTR(str(?start),1,10) AS ?mandate_start) (SUBSTR(str(?mem_end),1,10) AS ?mandate_end) WHERE {
    ?wikidata p:P39 ?statement .
    ?statement ps:P39 [ wdt:P279* wd:Q18229570 ] ; pq:P580 ?start .
    OPTIONAL { ?statement pq:P582 ?mem_end }
    BIND(COALESCE(?mem_end, "3001-01-01T00:00:00Z"^^xsd:dateTime) as ?end)
    FILTER (?end > NOW())
    SERVICE wikibase:label { 
      bd:serviceParam wikibase:language "es,en". 
      ?wikidata rdfs:label ?name .
    }
 }

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?end") v8("?mandate_end") v7("?mandate_start") v5("?mem_end"):::projected v6("?name"):::projected v4("?start"):::projected v3("?statement") v2("?wikidata") a1((" ")) c8(["bd:serviceParam"]):::iri c10(["es,en"]):::literal c3(["wd:Q18229570"]):::iri f0[["?end > NOW()"]] f0 --> v6 v2 --"p:P39"--> v3 a1 --"p:direct/P279"--> c3 v3 --"p:statement/P39"--> a1 v3 --"p:qualifier/P580"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P582".-> v5 end bind1[/"?mem_end'3001-01-01T00:00:00Z^^xsd:dateTime'"/] v5 --o bind1 bind1 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 v2 --"rdfs:label"--> v6 end bind2[/"substring(str(?start),'1^^xsd:integer','10^^xsd:integer')"/] v4 --o bind2 bind2 --as--o v7 bind3[/"substring(str(?mem_end),'1^^xsd:integer','10^^xsd:integer')"/] v5 --o bind3 bind3 --as--o v8