query-70c5f1164cff4b7cf4464b697d30dca8
SPARQL query
Use at
- https://query.wikidata.org/sparql
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 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 ?itemLabel (?itemLabel as ?name) ?party ?district ?mandate_start ?mandate_end
WHERE
{
?item p:P39 ?statement .
?statement ps:P39/wdt:P279* wd:Q18711738 ; pq:P580 ?mandate_start .
OPTIONAL { ?statement pq:P582 ?mandate_end }
OPTIONAL { ?statement pq:P768 ?district }
OPTIONAL { ?statement pq:P4100 ?party }
OPTIONAL { ?item wdt:P4453 ?id }
BIND(COALESCE(?mandate_end, "3001-01-01T00:00:00Z"^^xsd:dateTime) as ?enddate)
FILTER (?enddate > NOW())
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,es". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?district"):::projected
v9("?enddate")
v8("?id"):::projected
v2("?item")
v5("?mandate_end"):::projected
v4("?mandate_start"):::projected
v9("?name")
v7("?party"):::projected
v3("?statement")
a1((" "))
c13(["#91;AUTO_LANGUAGE#93;,en,es"]):::literal
c4(["wd:Q18711738"]):::iri
c11(["bd:serviceParam"]):::iri
f0[["?enddate > NOW()"]]
f0 --> v9
v2 --"p:P39"--> v3
v3 --"p:statement/P39"--> a1
a1 --"p:direct/P279"--> c4
v3 --"p:qualifier/P580"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P582".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P768".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P4100".-> v7
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P4453".-> v8
end
bind1[/"?mandate_end'3001-01-01T00:00:00Z^^xsd:dateTime'"/]
v5 --o bind1
bind1 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
bind2[/"?itemLabel"/]
null --o bind2
bind2 --as--o v9