query-c2e0487dfdfa2fa8b8e8b715cbe4d209

rq turtle/ttl

Captains list for the Royal Navy SELECT DISTINCT ?person ?personLabel ?timeCaptain ?threeID { # allow the report to work for different years BIND ("1741-03-01"^^xsd:dateTime AS ?timeMin) . BIND ("1784-01-01"^^xsd:dateTime AS ?timeReport) .

# person in Royal Navy ?person wdt:P241 wd:Q172771 .

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

# military rank -- should have a start time # captain (Royal Navy) wd:Q5036514

?person p:P410 ?stmtCaptain . ?stmtCaptain ps:P410 wd:Q5036514 . ?stmtCaptain pq:P580 ?timeCaptain .

# Three Decks ID optional { ?person wdt:P7389 ?threeID . }

# get time of death (some have multiple death dates) ?person wdt:P570 ?timeDeath . filter ( ?timeReport <= ?timeDeath) .

filter ( ?timeMin <= ?timeCaptain) . filter ( ?timeReport >= ?timeCaptain) .

# occupation naval officer # ?person wdt:P106 wd:Q10669499

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

} ORDER BY ?timeCaptain

Use at

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 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#>
# Captains list for the Royal Navy
SELECT DISTINCT ?person ?personLabel ?timeCaptain ?threeID
{ 
  # allow the report to work for different years
  BIND ("1741-03-01"^^xsd:date AS ?timeMin) .
  BIND ("1784-01-01"^^xsd:date AS ?timeReport) .

  # person in Royal Navy
  ?person wdt:P241 wd:Q172771 .

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


  # military rank -- should have a start time
  # captain (Royal Navy) wd:Q5036514

  ?person p:P410 ?stmtCaptain .
  ?stmtCaptain ps:P410 wd:Q5036514 .
  ?stmtCaptain pq:P580 ?timeCaptain .

  # Three Decks ID
  optional {
      ?person wdt:P7389 ?threeID .
  }

  # get time  of death (some have multiple death dates)
  ?person wdt:P570 ?timeDeath .
  filter ( ?timeReport <= ?timeDeath)  .

  filter ( ?timeMin <= ?timeCaptain) .
  filter ( ?timeReport >= ?timeCaptain) .

  # occupation naval officer
  # ?person wdt:P106 wd:Q10669499

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

} ORDER BY ?timeCaptain

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?person"):::projected v6("?stmtCaptain") v7("?threeID"):::projected v1("?timeCaptain"):::projected v4("?timeDeath") v5("?timeMin") v5("?timeReport") c14(["en"]):::literal c12(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c2(["wd:Q172771"]):::iri c7(["wd:Q5036514"]):::iri f0[["?timeReport >= ?timeCaptain"]] f0 --> v5 f0 --> v1 f1[["?timeMin <= ?timeCaptain"]] f1 --> v5 f1 --> v1 f2[["?timeReport <= ?timeDeath"]] f2 --> v5 f2 --> v4 bind3[/"'1741-03-01^^xsd:date'"/] bind3 --as--o v5 bind4[/"'1784-01-01^^xsd:date'"/] bind4 --as--o v5 v5 --"p:direct/P241"--> c2 v5 --"p:direct/P31"--> c4 v5 --"p:P410"--> v6 v6 --"p:statement/P410"--> c7 v6 --"p:qualifier/P580"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P7389".-> v7 end v5 --"p:direct/P570"--> v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end