query-62ec897009c91b0516148751274b52fb

rq turtle/ttl

Brothers without property 07:46, 9 June 2021 (UTC)) talk (LuckyzI would like to write a query that extracts couples of Italians born in the same place with the same surname in the interval of 10 years not having brothers / sisters but I don't know where to start from. Could Anybody help me?

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT * 
{
    ?item1 wdt:P19 / wdt:P17 wd:Q38 ; wdt:P734 ?fn .
    ?item2 wdt:P19 / wdt:P17 wd:Q38 ; wdt:P734 ?fn .

    FILTER( ?item != ?item2 )
    ?item1 wdt:P569 ?d1 . 
    ?item2 wdt:P569 ?d2 . 
    FILTER( ABS( YEAR(?d1) - YEAR(?d2) ) < 10 ) 
    ?item1 wdt:P21 wd:Q6581097 .
    ?item2 wdt:P21 wd:Q6581097 .
    FILTER NOT EXISTS { ?item1 wdt:P3373 ?item2 }
}  
LIMIT 3

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?d1"):::projected v4("?d2"):::projected v6("?fn"):::projected v5("?item") v1("?item1"):::projected v2("?item2"):::projected a1((" ")) a2((" ")) c5(["wd:Q38"]):::iri c9(["wd:Q6581097"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P3373"--> e0v2 e0v1("?item1"):::projected e0v2("?item2"):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 v1 --"wdt:P3373"--> v2 f1[["numeric-abs(year-from-dateTime(?d1) - year-from-dateTime(?d2)) < '10^^xsd:integer'"]] f1 --> v3 f1 --> v4 f2[["?item != ?item2"]] f2 --> v5 f2 --> v2 v1 --"wdt:P19"--> a1 a1 --"wdt:P17"--> c5 v1 --"wdt:P734"--> v6 v2 --"wdt:P19"--> a2 a2 --"wdt:P17"--> c5 v2 --"wdt:P734"--> v6 v1 --"wdt:P569"--> v3 v2 --"wdt:P569"--> v4 v1 --"wdt:P21"--> c9 v2 --"wdt:P21"--> c9