query-67dc8d9ce1f17358ded950f53fbfe0ff

rq turtle/ttl

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". } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
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#>
#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". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?assumedOffice"):::projected v7("?dob"):::projected v9("?dod"):::projected v5("?endOffice"):::projected v6("?gender") v11("?height"):::projected v4("?ordinal"):::projected v1("?pm"):::projected v8("?pob") v10("?pod") v2("?posheld") c14(["bd:serviceParam"]):::iri c3(["wd:Q839078"]):::iri c16(["fr,en"]):::literal v1 --"p:P39"--> v2 v2 --"p:statement/P39"--> c3 v2 --"p:qualifier/P580"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P1545".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P582".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P21".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P569".-> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P19".-> v8 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P570".-> v9 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P20".-> v10 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P2048".-> v11 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end