query-42afdcfd228e703816af419224374c8c

rq turtle/ttl


https://www.wikidata.org/wiki/User:Stefan_K%C3%BChn/

---

SELECT DISTINCT ?item ?itemLabel ?firstnameLabel ?lastnameLabel ?itemDescription ?reason ?day ?testday ?diffyear ?image WHERE { {?item wdt:P19 wd:Q1715} # Person mit Geburtsort = Hannover UNION {?item wdt:P20 wd:Q1715} # Person mit Todesort = Hannover UNION {?item wdt:P937 wd:Q1715} # Person mit Wirkungsort = Hannover UNION {?item wdt:P108 wd:Q678982} # Personen die an der Leibniz-Uni angestellt sind/waren

BIND( now() as ?testday) # Testdatum (heute)
#BIND("2019-03-22T00:00:00Z"^^xsd:dateTime as ?testday)  # Testdatum (beliebiger Tag)

{?item p:P569 [ a wikibase:BestRank ; # Geburtstag
       psv:P569 [ wikibase:timeValue ?day;
       wikibase:timePrecision ?precision_day ] ] 
 FILTER (?precision_day > 8 ) # Geburtstag vollständig (YYYY-MM-DD)
 BIND( 'Geburtstag' as ?reason)                     
}
UNION
 {?item p:P570 [ a wikibase:BestRank ; # Todestag
       psv:P570 [ wikibase:timeValue ?day;
       wikibase:timePrecision ?precision_day ] ] 
 FILTER (?precision_day > 8 ) # Todestag vollständig (YYYY-MM-DD)
 BIND( 'Todestag' as ?reason)
 }

FILTER (MONTH(?day) = MONTH(?testday)) # gleicher Monat
FILTER (  DAY(?day) =   DAY(?testday)) # gleicher Tag

BIND (YEAR(?testday)-YEAR(?day) AS ?diffyear) # Jahresdifferenz errechnen 
BIND (floor(?diffyear - (5 * floor(?diffyear/5))) AS ?mod) # Modula 5  
FILTER (?mod = 0) # nur Jahre wo Rest = 0 (5,10,15,20,25,...)

OPTIONAL { ?item wdt:P734 ?lastname . } # Nachname
OPTIONAL { ?item wdt:P735 ?firstname . } # Vorname
OPTIONAL { ?item wdt:P18 ?image . } # optional Bild
SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en,[AUTO_LANGUAGE]"}

} ORDER BY DESC(?diffyear)

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#---
# https://www.wikidata.org/wiki/User:Stefan_K%C3%BChn/
#---
SELECT DISTINCT ?item ?itemLabel ?firstnameLabel ?lastnameLabel ?itemDescription ?reason ?day ?testday ?diffyear ?image 
WHERE
{
    {?item wdt:P19 wd:Q1715} # Person mit Geburtsort = Hannover
    UNION
    {?item wdt:P20 wd:Q1715} # Person mit Todesort = Hannover
    UNION
    {?item wdt:P937 wd:Q1715} # Person mit Wirkungsort = Hannover
    UNION
    {?item wdt:P108 wd:Q678982} # Personen die an der Leibniz-Uni angestellt sind/waren


    BIND( now() as ?testday) # Testdatum (heute)
    #BIND("2019-03-22T00:00:00Z"^^xsd:dateTime as ?testday)  # Testdatum (beliebiger Tag)

    {?item p:P569 [ a wikibase:BestRank ; # Geburtstag
           psv:P569 [ wikibase:timeValue ?day;
           wikibase:timePrecision ?precision_day ] ] 
     FILTER (?precision_day > 8 ) # Geburtstag vollständig (YYYY-MM-DD)
     BIND( 'Geburtstag' as ?reason)                     
    }
    UNION
     {?item p:P570 [ a wikibase:BestRank ; # Todestag
           psv:P570 [ wikibase:timeValue ?day;
           wikibase:timePrecision ?precision_day ] ] 
     FILTER (?precision_day > 8 ) # Todestag vollständig (YYYY-MM-DD)
     BIND( 'Todestag' as ?reason)
     }

    FILTER (MONTH(?day) = MONTH(?testday)) # gleicher Monat
    FILTER (  DAY(?day) =   DAY(?testday)) # gleicher Tag

    BIND (YEAR(?testday)-YEAR(?day) AS ?diffyear) # Jahresdifferenz errechnen 
    BIND (floor(?diffyear - (5 * floor(?diffyear/5))) AS ?mod) # Modula 5  
    FILTER (?mod = 0) # nur Jahre wo Rest = 0 (5,10,15,20,25,...)

    OPTIONAL { ?item wdt:P734 ?lastname . } # Nachname
    OPTIONAL { ?item wdt:P735 ?firstname . } # Vorname
    OPTIONAL { ?item wdt:P18 ?image . } # optional Bild
    SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en,[AUTO_LANGUAGE]"}
} 
ORDER BY DESC(?diffyear)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?day"):::projected v8("?diffyear"):::projected v9("?firstname") v10("?image"):::projected v5("?item"):::projected v8("?lastname") v8("?mod") v6("?precision_day") v8("?reason"):::projected v6("?testday"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) c3(["wd:Q1715"]):::iri c10(["wikibase:BestRank"]):::iri c21(["bd:serviceParam"]):::iri c7(["wd:Q678982"]):::iri c23(["de,en,#91;AUTO_LANGUAGE#93;"]):::literal f0[["?mod = '0^^xsd:integer'"]] f0 --> v8 f1[["day-from-dateTime(?day) = day-from-dateTime(?testday)"]] f1 --> v3 f1 --> v6 f2[["month-from-dateTime(?day) = month-from-dateTime(?testday)"]] f2 --> v3 f2 --> v6 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P108"--> c7 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P937"--> c3 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P20"--> c3 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P19"--> c3 end union0r <== or ==> union0l end bind3[/"NOW()"/] bind3 --as--o v6 subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; f4[["?precision_day > '8^^xsd:integer'"]] f4 --> v6 a3 --"a"--> c10 a4 --"wikibase:timeValue"--> v3 a4 --"wikibase:timePrecision"--> v6 a3 --"p:statement/value/P570"--> a4 v5 --"p:P570"--> a3 bind5[/"'Todestag'"/] bind5 --as--o v8 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; f6[["?precision_day > '8^^xsd:integer'"]] f6 --> v6 a1 --"a"--> c10 a2 --"wikibase:timeValue"--> v3 a2 --"wikibase:timePrecision"--> v6 a1 --"p:statement/value/P569"--> a2 v5 --"p:P569"--> a1 bind7[/"'Geburtstag'"/] bind7 --as--o v8 end union3r <== or ==> union3l end bind8[/"year-from-dateTime(?testday) - year-from-dateTime(?day)"/] v6 --o bind8 v3 --o bind8 bind8 --as--o v8 bind9[/"numeric-floor(?diffyear - '5^^xsd:integer' * numeric-floor(?diffyear / '5^^xsd:integer'))"/] v8 --o bind9 bind9 --as--o v8 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P734".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P735".-> v9 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P18".-> v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c21 --"wikibase:language"--> c23 end