query-e1d5535b02662197a90a6c870465c4d2

rq turtle/ttl

Find a bad occupation SELECT ?person ?personLabel ?givenLabel ?familyLabel ?timeCaptain ?timeDeath ?threeID WHERE {

# Human ?person wdt:P31 wd:Q5 .

# branch of service is Royal Navy ?person wdt:P241 wd:Q172771 .

# for officers (not sailors) want to see occupation is a naval officer # occupation naval officer # FILTER not exists { ?person wdt:P106 wd:Q10669499 .}

# occupation Q47064 military personnel is not an occupation # ?person wdt:P106 wd:Q47064 .

# occupation Q189290 military officer is too generic # ?person wdt:P106 wd:Q189290 .

# admiral of the fleet (not RN) # ?person wdt:P410 wd:Q842486 . # admiral (not RN) ?person wdt:P410 wd:Q132851 . # vice admiral (not RN) # ?person wdt:P410 wd:Q214443 . # rear admiral (not RN) # ?person wdt:P410 wd:Q156945 . # captain (not RN) # ?person wdt:P410 wd:Q163500 .

optional { # given name ?person wdt:P735 ?given . }

optional { # family name ?person wdt:P734 ?family . }

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

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

optional { ?person wdt:P570 ?timeDeath . }

SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } ORDER BY ?timeDeath

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#>
# Find a bad occupation
SELECT ?person ?personLabel ?givenLabel ?familyLabel ?timeCaptain ?timeDeath ?threeID WHERE {

  # Human
  ?person wdt:P31 wd:Q5 .

  # branch of service is Royal Navy
  ?person wdt:P241 wd:Q172771 .

  # for officers (not sailors) want to see occupation is a naval officer
  # occupation naval officer
  # FILTER not exists { ?person wdt:P106 wd:Q10669499 .}

  # occupation Q47064 military personnel is not an occupation
  # ?person wdt:P106 wd:Q47064 .

  # occupation Q189290 military officer is too generic
  # ?person wdt:P106 wd:Q189290 .

  # admiral of the fleet (not RN)
  # ?person wdt:P410 wd:Q842486 .
  # admiral (not RN)
  ?person wdt:P410 wd:Q132851 .
  # vice admiral (not RN)
  # ?person wdt:P410 wd:Q214443 .
  # rear admiral (not RN)
  # ?person wdt:P410 wd:Q156945 .
  # captain (not RN)
  # ?person wdt:P410 wd:Q163500 .

  optional {
    # given name
    ?person wdt:P735 ?given .
  }

  optional {
    # family name
    ?person wdt:P734 ?family .
  }

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

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

  optional {
    ?person wdt:P570 ?timeDeath .
  }

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
ORDER BY ?timeDeath

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?family") v3("?given") v2("?person"):::projected v6("?stmtCaptain") v5("?threeID"):::projected v7("?timeCaptain"):::projected v1("?timeDeath"):::projected c18(["en"]):::literal c16(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c6(["wd:Q132851"]):::iri c4(["wd:Q172771"]):::iri c12(["wd:Q5036514"]):::iri v2 --"p:direct/P31"--> c2 v2 --"p:direct/P241"--> c4 v2 --"p:direct/P410"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P735".-> v3 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P734".-> v4 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P7389".-> v5 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:P410".-> v6 v6 --"p:statement/P410"--> c12 v6 --"p:qualifier/P580"--> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P570".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c18 end