query-9a509e06a154cf7e17ba0d8b09dd1526

rq turtle/ttl

20:33, 1 January 2021 (UTC) JuraCounts 325 in a few seconds --- and with null-values for missing dates): (Q3391743)visual artist : helped a lot. thx. Now my query looks like this (with Jura1@

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?itemDescription (GROUP_CONCAT(DISTINCT ?profLabel; SEPARATOR=', ') AS ?profLabels) ?yearOfBirth ?yearOfDeath ?firstnameLabel ?lastnameLabel where 
{
    ### variable search parameters
    BIND (1960 as ?dateOfWork) .
    BIND ("^D" as ?firstnamePattern). # first letter of initials, assuming firstname
    BIND ("^K" as ?lastnamePattern). # second letter of initials, assuming lastname
    ###

    optional {?item wdt:P569 ?d1.}
    optional {?item wdt:P570 ?d2.}
    BIND(IF(BOUND(?d1), year(?d1), 0) AS ?yearOfBirth) . # use null value
    BIND(IF(BOUND(?d2), year(?d2), 3000) AS ?yearOfDeath) .
    hint:Prior hint:rangeSafe true .
    ?item wdt:P106/wdt:P279* wd:Q3391743 . #Q483501 
    ?item wdt:P106 ?prof.
    OPTIONAL {
      ?prof rdfs:label ?profLiteral .
      FILTER(LANG(?profLiteral) = 'de') .
    }

    BIND(IF(BOUND(?prof), IF(BOUND(?profLiteral), ?profLiteral, STRAFTER(STR(?prof), 'entity/')), 'no Prof') AS ?profLabel) .

    FILTER( ?yearOfBirth+20 <= ?dateOfWork && ?yearOfDeath >= ?dateOfWork )
    ?item wdt:P735 / wdt:P1705 ?firstname . FILTER( REGEX(?firstname, "^D" ) ) # ok
    ?item wdt:P734 / wdt:P1705 ?lastname . FILTER( REGEX(?lastname, "^K" ) )
    #?item wdt:P735 / wdt:P1705 ?firstname . FILTER( REGEX(?firstname, ?firstnamePattern ) ) # not ok
    #?item wdt:P734 / wdt:P1705 ?lastname . FILTER( REGEX(?lastname, ?lastnamePattern ) )
    OPTIONAL { ?firstname rdfs:label ?firstnameLabel . FILTER(LANG(?firstnameLabel) = 'de') . }
    OPTIONAL { ?lastname rdfs:label ?lastnameLabel . FILTER(LANG(?lastnameLabel) = 'de') . }

    SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE,de,en]' }
} group by ?item ?itemLabel ?itemDescription ?profLabels ?yearOfBirth ?yearOfDeath ?firstnameLabel ?lastnameLabel

Query found at