query-6a266f2e1d06816cdbe69fc955e7d5e0

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?itemDescription ?td ?p ?pLabel ?pDescription ?dob ?dod ?gap where
{
   {
  SELECT ?item ?itemLabel ?itemDescription ?td ?p ?pLabel ?pDescription ?dob ?dod where
{

    { ?item p:P225 [ pq:P574 ?td ; pq:P405 ?p ] .
    ?p wdt:P569 ?dob . FILTER( YEAR(?td) < YEAR(?dob) + 20) }
    UNION
    { ?item p:P225 [ pq:P574 ?td ; pq:P405 ?p ] .
      ?p wdt:P570 ?dod . FILTER( YEAR(?td) > YEAR(?dod) + 2) }
} limit 2500 }  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  bind(coalesce(year(?dob)+20,year(?dod)+2) as ?edate)
  bind((year(?td)-?edate) as ?gap)
  } order by desc(?gap)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?dob"):::projected v6("?dod"):::projected v7("?edate") v8("?gap"):::projected v5("?item"):::projected v4("?p"):::projected v2("?td"):::projected a1((" ")) a2((" ")) c9(["bd:serviceParam"]):::iri c11(["en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["year-from-dateTime(?td) > year-from-dateTime(?dod) + '2^^xsd:integer'"]] f0 --> v2 f0 --> v6 a2 --"p:qualifier/P574"--> v2 a2 --"p:qualifier/P405"--> v4 v5 --"p:P225"--> a2 v4 --"p:direct/P570"--> v6 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f1[["year-from-dateTime(?td) < year-from-dateTime(?dob) + '20^^xsd:integer'"]] f1 --> v2 f1 --> v3 a1 --"p:qualifier/P574"--> v2 a1 --"p:qualifier/P405"--> v4 v5 --"p:P225"--> a1 v4 --"p:direct/P569"--> v3 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind2[/"year-from-dateTime(?dob) + '+20^^xsd:integer'year-from-dateTime(?dod) + '+2^^xsd:integer'"/] v3 --o bind2 v6 --o bind2 bind2 --as--o v7 bind3[/"year-from-dateTime(?td) - ?edate"/] v2 --o bind3 v7 --o bind3 bind3 --as--o v8