query-d1cfcfe92d8b4fd9cf2506c87d8c83b7

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?dob1 ?precision1 ?dob2 ?precision2 ?problem_type
WHERE 
{ ?item wdt:P27 wd:Q20.               # country of citizenship=Norway
  ?item p:P569 ?p569stm1 .
  ?p569stm1 ps:P569 ?dob1 .             # must have dob
  ?p569stm1 psv:P569 [wikibase:timePrecision ?dp1] . # find out time precision
  ?item p:P569 ?p569stm2 .
  ?p569stm2 ps:P569 ?dob2 .
  ?p569stm2 psv:P569 [wikibase:timePrecision ?dp2] .
  FILTER(?dp1<?dp2 || (?dp1=?dp2 && ?dob1<?dob2))                  # more than one dob and with different precision or with same precision but different date
  BIND(IF(?dp1<?dp2,'different time precision','different dates') AS ?problem_type)
  BIND(IF(?dp1=11,'day',IF(?dp1=10,'month',IF(?dp1=9,'year',IF(?dp1=8,'decade',IF(?dp1=7,'century','other'))))) AS ?precision1) # convert code for time precision to English
  BIND(IF(?dp2=11,'day',IF(?dp2=10,'month',IF(?dp2=9,'year',IF(?dp2=8,'decade',IF(?dp2=7,'century','other'))))) AS ?precision2) # convert code for time precision to English
  BIND (year(?dob1) as ?year)          # convert dob to years
  FILTER (?year >= 1710)              # filter for dob later than or equal to 1710
  FILTER (?year <= 1911)              # filter for dob prior to or equal to 1911
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],no,en". } # get labels
} ORDER BY ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?dob1"):::projected v6("?dob2"):::projected v3("?dp1") v4("?dp2") v7("?item"):::projected v1("?itemLabel"):::projected v8("?p569stm1") v9("?p569stm2") v11("?precision1"):::projected v12("?precision2"):::projected v10("?problem_type"):::projected v13("?year") a1((" ")) a2((" ")) c10(["bd:serviceParam"]):::iri c4(["wd:Q20"]):::iri c12(["#91;AUTO_LANGUAGE#93;,no,en"]):::literal f0[["?year <= '1911^^xsd:integer'"]] f0 --> v13 f1[["?year >= '1710^^xsd:integer'"]] f1 --> v13 f2[["(?dp1 < ?dp2 || ?dp1 = ?dp2?dob1 < ?dob2)"]] f2 --> v3 f2 --> v4 f2 --> v5 f2 --> v6 v7 --"p:direct/P27"--> c4 v7 --"p:P569"--> v8 v8 --"p:statement/P569"--> v5 a1 --"wikibase:timePrecision"--> v3 v8 --"p:statement/value/P569"--> a1 v7 --"p:P569"--> v9 v9 --"p:statement/P569"--> v6 a2 --"wikibase:timePrecision"--> v4 v9 --"p:statement/value/P569"--> a2 bind3[/"if(?dp1 < ?dp2,'different time precision','different dates')"/] v3 --o bind3 v4 --o bind3 bind3 --as--o v10 bind4[/"if(?dp1 = '11^^xsd:integer','day',if(?dp1 = '10^^xsd:integer','month',if(?dp1 = '9^^xsd:integer','year',if(?dp1 = '8^^xsd:integer','decade',if(?dp1 = '7^^xsd:integer','century','other')))))"/] v3 --o bind4 bind4 --as--o v11 bind5[/"if(?dp2 = '11^^xsd:integer','day',if(?dp2 = '10^^xsd:integer','month',if(?dp2 = '9^^xsd:integer','year',if(?dp2 = '8^^xsd:integer','decade',if(?dp2 = '7^^xsd:integer','century','other')))))"/] v4 --o bind5 bind5 --as--o v12 bind6[/"year-from-dateTime(?dob1)"/] v5 --o bind6 bind6 --as--o v13 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end