query-d8c0deef383521fdfa9ac187731fc4ec
SPARQL query
Use at
- https://query.wikidata.org/sparql
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 ?url ?honorific_id ?itemLabel (?itemLabel as ?name) ?role ?district_id ?party_id
WHERE
{
?item p:P39 ?statement .
?statement ps:P39/wdt:P279* wd:Q17510786 ; pq:P580 ?start .
OPTIONAL { ?statement pq:P582 ?end }
OPTIONAL { ?statement pq:P768 ?district_id }
OPTIONAL { ?district_id rdfs:label ?district . FILTER(lang(?en_label)="en") }
OPTIONAL { ?statement pq:P4100 ?party_id }
OPTIONAL { ?statement pq:P2868 ?role }
OPTIONAL { ?item wdt:P511 ?honorific_id }
OPTIONAL { ?item wdt:P973 ?url }
FILTER(!BOUND(?end) || ?end > NOW())
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?start ?end
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?district")
v6("?district_id"):::projected
v3("?en_label")
v2("?end")
v10("?honorific_id"):::projected
v4("?item")
v12("?name")
v8("?party_id"):::projected
v9("?role"):::projected
v1("?start")
v5("?statement")
v11("?url"):::projected
a1((" "))
c15(["bd:serviceParam"]):::iri
c17(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c5(["wd:Q17510786"]):::iri
f0[["(not bound(?end) || ?end > NOW())"]]
f0 --> v2
v4 --"p:P39"--> v5
v5 --"p:statement/P39"--> a1
a1 --"p:direct/P279"--> c5
v5 --"p:qualifier/P580"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P582".-> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P768".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:label".-> v7
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P4100".-> v8
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P2868".-> v9
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P511".-> v10
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P973".-> v11
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
end
bind1[/"?itemLabel"/]
null --o bind1
bind1 --as--o v12