query-336b84bd79c91849690fe2c7797a4cba

rq turtle/ttl

rank implies branch SELECT DISTINCT ?person ?personLabel ?occupationLabel ?branchLabel ?birthDate ?rankLabel ?rankDate ?threeID { # military rank -- should have a start time

# select a rank

# admiral of the fleet wd:Q842486 . # admiral of the fleet (Royal Navy) wd:Q2501631 BIND (wd:Q2501631 AS ?rank) .

# admiral # admiral (Royal Navy) wd:Q2916006 # BIND (wd:Q2916006 AS ?rank) .

# vice admiral wd:Q214443 . # vice admiral (Royal Navy) wd:Q4902790 # BIND (wd:Q4902790 AS ?rank) .

# rear admiral wd:Q156945 # rear admiral (Royal Navy) wd:Q15615347 # BIND (wd:Q15615347 AS ?rank) .

# captain # captain (Royal Navy) wd:Q5036514 # BIND (wd:Q5036514 AS ?rank) .

# flag officer (watch out: rear admiral is an instance of military rank) wd:Q977459 .

# human instead of fictional ?person wdt:P31 wd:Q5 .

# person has that rank ?person p:P410 ?stmtRank . ?stmtRank ps:P410 ?rank . optional { # date of rank if known ?stmtRank pq:P580 ?rankDate . }

# person in Royal Navy # FILTER not exists {?person wdt:P241 wd:Q172771 .}. optional { ?person wdt:P241 ?branch . }

# occupation is naval officer # FILTER not exists {?person wdt:P106 wd:Q10669499 .}. optional { # occupation ?person wdt:P106 ?occupation . }

# get the Three Decks people Id if available optional { ?person wdt:P7389 ?threeID . } .

# order by birthdate optional { ?person wdt:P569 ?birthDate . }

SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .} .

} ORDER BY ?birthDate

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#>
# rank implies branch
SELECT DISTINCT ?person ?personLabel ?occupationLabel ?branchLabel ?birthDate ?rankLabel ?rankDate ?threeID
{ 
  # military rank -- should have a start time

  # select a rank

  # admiral of the fleet wd:Q842486 .
  # admiral of the fleet (Royal Navy) wd:Q2501631
  BIND (wd:Q2501631 AS ?rank) .

  # admiral
  # admiral (Royal Navy) wd:Q2916006
  # BIND (wd:Q2916006 AS ?rank) .

  # vice admiral wd:Q214443 .
  # vice admiral (Royal Navy) wd:Q4902790
  # BIND (wd:Q4902790 AS ?rank) .

  # rear admiral wd:Q156945
  # rear admiral (Royal Navy) wd:Q15615347
  # BIND (wd:Q15615347 AS ?rank) .

  # captain
  # captain (Royal Navy) wd:Q5036514
  # BIND (wd:Q5036514 AS ?rank) .

  # flag officer (watch out: rear admiral is an instance of military rank) wd:Q977459 .

  # human instead of fictional
  ?person wdt:P31 wd:Q5 .

  # person has that rank
  ?person p:P410 ?stmtRank .
  ?stmtRank ps:P410 ?rank .
  optional {
    # date of rank if known
    ?stmtRank pq:P580 ?rankDate .
  }

  # person in Royal Navy
  # FILTER not exists {?person wdt:P241 wd:Q172771 .}.
  optional {
    ?person wdt:P241 ?branch .
  }

  # occupation is naval officer
  # FILTER not exists {?person wdt:P106 wd:Q10669499 .}.
  optional {
    # occupation
    ?person wdt:P106 ?occupation .
  }

  # get the Three Decks people Id if available
  optional {
    ?person wdt:P7389 ?threeID .
  } .

  # order by birthdate
  optional {
    ?person wdt:P569 ?birthDate .
  }

  SERVICE wikibase:label {
     bd:serviceParam wikibase:language "en" .} .

} ORDER BY ?birthDate

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?birthDate"):::projected v6("?branch") v7("?occupation") v3("?person"):::projected v2("?rank") v5("?rankDate"):::projected v4("?stmtRank") v8("?threeID"):::projected c13(["en"]):::literal c11(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri bind0[/"'wd:Q2501631'"/] bind0 --as--o v2 v3 --"p:direct/P31"--> c2 v3 --"p:P410"--> v4 v4 --"p:statement/P410"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P580".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P241".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P106".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P7389".-> v8 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P569".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end