User:Mcarondiotte/Prime Ministers of Canada
Query
edit#title:Prime Ministers of Canada
SELECT ?pm ?pmLabel ?genderLabel ?dob ?pobLabel ?dod ?podLabel ?height ?assumedOffice ?endOffice ?ordinal WHERE {
# Get all Premiers
?pm p:P39 ?posheld. # with position held
# Check on the position as Prime Minister of Canada
?posheld ps:P39 wd:Q839078 ; # Position held is in Prime Minister of Canada
pq:P580 ?assumedOffice . # should have a starttime
OPTIONAL { ?posheld pq:P1545 ?ordinal . } # but not necessarily an ordinal
OPTIONAL { ?posheld pq:P582 ?endOffice . } # but not necessarily an endtime
OPTIONAL{ ?pm wdt:P21 ?gender . } # get gender
OPTIONAL{ ?pm wdt:P569 ?dob . } # get date of birth
OPTIONAL{ ?pm wdt:P19 ?pob . } # get place of birth
OPTIONAL{ ?pm wdt:P570 ?dod . } # get date of death
OPTIONAL{ ?pm wdt:P20 ?pod . } # get place of death
OPTIONAL{ ?pm wdt:P2048 ?height . } # get height
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en". }
}
Useful links
editAdapted from: SPARQL query service examples