query-965fb79df986e9466fc9c6e9215a6306
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 prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?name ?constituency ?party ?gender ?birth_date ?source WHERE {
?item p:P39 ?mem .
?mem ps:P39 wd:Q18607856; pq:P2937 wd:Q45380990 .
FILTER NOT EXISTS { ?mem pq:P582 [] }
OPTIONAL { ?item p:P973/pq:P1810 ?name2 }
OPTIONAL { ?item wdt:P21 ?genderItem }
OPTIONAL { ?item wdt:P569 ?DoB . BIND(SUBSTR(STR(?DoB), 1, 10) AS ?birth_date) }
OPTIONAL { ?mem pq:P4100|pq:P102 ?group }
OPTIONAL { ?mem pq:P768 ?area }
OPTIONAL { ?mem prov:wasDerivedFrom [ pr:P854 ?source ] }
?item rdfs:label ?name3 . FILTER(LANG(?name3) = 'en') .
BIND(COALESCE(?name2, ?name3) AS ?name) .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?area rdfs:label ?constituency .
?group rdfs:label ?party .
?genderItem rdfs:label ?gender .
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?DoB")
v9("?area")
v7("?birth_date"):::projected
v12("?constituency"):::projected
v14("?gender"):::projected
v5("?genderItem")
v8("?group")
v3("?item"):::projected
v2("?mem")
v11("?name"):::projected
v4("?name2")
v1("?name3")
v13("?party"):::projected
v10("?source"):::projected
a1((" "))
a2((" "))
a3((" "))
c1(["en"]):::literal
c7(["wd:Q45380990"]):::iri
c19(["bd:serviceParam"]):::iri
c5(["wd:Q18607856"]):::iri
f0[["?name3 = 'en'"]]
f0 --> v1
f1[["not "]]
subgraph f1e0["Exists Clause"]
e0v1 --"p:qualifier/P582"--> e0a1
e0v1("?mem"):::projected
e0a1((" ")):::projected
end
f1--EXISTS--> f1e0
f1 --> v2
f1 --> c2
f1 --> a1
v2 --"p:qualifier/P582"--> a1
v3 --"p:P39"--> v2
v2 --"p:statement/P39"--> c5
v2 --"p:qualifier/P2937"--> c7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:P973".-> a2
a2 --"p:qualifier/P1810"--> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P21".-> v5
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P569".-> v6
bind2[/"substring(str(?DoB),'1^^xsd:integer','10^^xsd:integer')"/]
v6 --o bind2
bind2 --as--o v7
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 -."p:qualifier/P102".-> v8
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:qualifier/P4100"--> v8
end
union0r <== or ==> union0l
end
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P768".-> v9
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
a3 -."p:reference/P854".-> v10
v2 --"prov:wasDerivedFrom"--> a3
end
v3 --"rdfs:label"--> v1
bind3[/"?name2?name3"/]
v4 --o bind3
v1 --o bind3
bind3 --as--o v11
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c19 --"wikibase:language"--> c1
v9 --"rdfs:label"--> v12
v8 --"rdfs:label"--> v13
v5 --"rdfs:label"--> v14
end