query-20d976785155eb430aaf977914b70645
Presidents of the United States with their wifes
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
SELECT ?ordinal ?presidentLabel (GROUP_CONCAT(?spouseName;separator=", ") AS ?spouses) (COUNT(?spouse) AS ?spouseCount) ?president WHERE {
?president wdt:P31 wd:Q5 .
?president p:P26 ?spouse_statement .
?spouse_statement v:P26 ?spouse .
?spouse rdfs:label ?spouseName . FILTER(lang(?spouseName) = "en")
?president p:P39 ?presidentBlock . ?presidentBlock v:P39 wd:Q11696 . ?presidentBlock pq:P1545 ?ordinal .
SERVICE wikibase:label{bd:serviceParam wikibase:language "en"}
}
GROUP BY ?ordinal ?president ?presidentLabel
ORDER BY ASC(xsd:integer(?ordinal))
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?ordinal"):::projected
v3("?president"):::projected
v6("?presidentBlock")
v5("?spouse"):::projected
v8("?spouseCount")
v2("?spouseName"):::projected
v4("?spouse_statement")
v7("?spouses")
c1(["en"]):::literal
c12(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
c9(["wd:Q11696"]):::iri
f0[["?spouseName = 'en'"]]
f0 --> v2
v3 --"p:direct/P31"--> c3
v3 --"p:P26"--> v4
v4 --"p:statement/P26"--> v5
v5 --"rdfs:label"--> v2
v3 --"p:P39"--> v6
v6 --"p:statement/P39"--> c9
v6 --"p:qualifier/P1545"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c1
end
bind3[/"?spouseName"/]
v2 --o bind3
bind3 --as--o v7
bind4[/"count(?spouse)"/]
v5 --o bind4
bind4 --as--o v8