query-4808f0f58fb892c1c1a867342d4682ad

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?s1Label ?s2Label (year(?dob) AS ?yob) (year(?dod) AS ?yod) ?pobLabel ?podLabel
WHERE 
{
  ?item wdt:P31 wd:Q5
  {?item wdt:P27 wd:Q20}  #citizen of Norway
  UNION                    #or  
  {?item wdt:P27 wd:Q189} #citizen of Iceland

  {?item wdt:P569 ?dob . FILTER ((year(?dob) > 793) && ( year(?dob) < 1066 )) } 
  UNION
  {?item wdt:P570 ?dod . FILTER ((year(?dod) > 793) && (year(?dod) < 1066 ))  }

  OPTIONAL {?item wdt:P569 ?dob } .
  OPTIONAL {?item wdt:P570 ?dod } .

  BIND( IF (bound(?dob) && !isBlank(?dob) , year(?dob) , year(?dod) - 40) AS ?order_date) . 
  OPTIONAL {?item wdt:P19 ?pob} .
  OPTIONAL {?item wdt:P20 ?pod} .
  OPTIONAL {?item wdt:P27 ?s1 . FILTER(?s1 = wd:Q189)} .
  OPTIONAL {?item wdt:P27 ?s2 . FILTER(?s2 = wd:Q20)} .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?order_date ?yod ?yob ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?dob"):::projected v9("?dod"):::projected v7("?item"):::projected v4("?itemLabel"):::projected v10("?order_date") v10("?pob") v11("?pod") v6("?s1") v5("?s2") v12("?yob") v12("?yod") c1(["wd:Q20"]):::iri c13(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q189"]):::iri v7 --"wdt:P31"--> c4 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v7 --"wdt:P27"--> c2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v7 --"wdt:P27"--> c1 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; f0[["year-from-dateTime(?dod) > '793^^xsd:integer'year-from-dateTime(?dod) < '1066^^xsd:integer'"]] f0 --> v9 v7 --"wdt:P570"--> v9 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; f1[["year-from-dateTime(?dob) > '793^^xsd:integer'year-from-dateTime(?dob) < '1066^^xsd:integer'"]] f1 --> v8 v7 --"wdt:P569"--> v8 end union1r <== or ==> union1l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P569".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P570".-> v9 end bind2[/"if(bound(?dob)not isBlank(?dob),year-from-dateTime(?dob),year-from-dateTime(?dod) - '40^^xsd:integer')"/] v8 --o bind2 v9 --o bind2 bind2 --as--o v10 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P19".-> v10 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P20".-> v11 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P27".-> v6 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P27".-> v5 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end bind3[/"year-from-dateTime(?dob)"/] v8 --o bind3 bind3 --as--o v12 bind4[/"year-from-dateTime(?dod)"/] v9 --o bind4 bind4 --as--o v12