query-61f9cd0d8e543aa356b04b29253a3990
SPARQL query
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
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 (STRAFTER(STR(?item), STR(wd:)) AS ?wikidata)
WHERE {
?item p:P39 ?mem .
?mem ps:P39 wd:Q18558478 ; pq:P2937 wd:Q5487948 .
OPTIONAL { ?mem pq:P768 ?district }
OPTIONAL { ?mem pq:P4100 ?group }
FILTER NOT EXISTS { ?mem pq:P582 [] } # only current members
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?item rdfs:label ?name .
}
}
ORDER BY ?name
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?district")
v5("?group")
v3("?item"):::projected
v2("?mem")
v1("?name")
v6("?wikidata")
a1((" "))
c4(["wd:Q18558478"]):::iri
c12(["en"]):::literal
c10(["bd:serviceParam"]):::iri
c6(["wd:Q5487948"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"p:qualifier/P582"--> e0a1
e0v1("?mem"):::projected
e0a1((" ")):::projected
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> c1
f0 --> a1
v2 --"p:qualifier/P582"--> a1
v3 --"p:P39"--> v2
v2 --"p:statement/P39"--> c4
v2 --"p:qualifier/P2937"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P768".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P4100".-> v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
v3 --"rdfs:label"--> v1
end
bind1[/"substring-after(str(?item),str('wd:'))"/]
v3 --o bind1
bind1 --as--o v6