query-d397f6f081e96a56ac747b732533c1fb

rq turtle/ttl

pairs of persons that have the same date of birth AND share a place of birth (Brazil) with population lower than a certain threshold SELECT ?person1 ?person1Label ?person2 ?person2Label ?date_of_birth ?place_of_birth WHERE { ?place_of_birth wdt:P17 wd:Q155; #in Brazil wdt:P1082 ?population. FILTER(?population < 100000 ) # for places with huge population, use additional constraints for person1/person2 pair ?person1 wdt:P31 wd:Q5; #human wdt:P19 ?place_of_birth; wdt:P569 ?date_of_birth. ?person2 wdt:P31 wd:Q5; #human, empty P31 is also useful here wdt:P19 ?place_of_birth; wdt:P569 ?date_of_birth. FILTER(!(((DAY(?date_of_birth)) = 1 ) && ((MONTH(?date_of_birth)) = 1 ))) # I usually exclude January 1, too many false positives even with 1 day precision FILTER( ?person1 != ?person2) SERVICE wikibase:label { bd:serviceParam wikibase:language "pt,es,[AUTO_LANGUAGE]". } } ORDER BY DESC(?date_of_birth)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#pairs of persons that have the same date of birth AND share a place of birth (Brazil) with population lower than a certain threshold 
SELECT ?person1 ?person1Label ?person2 ?person2Label ?date_of_birth ?place_of_birth WHERE {
  ?place_of_birth wdt:P17 wd:Q155; #in Brazil
    wdt:P1082 ?population.
  FILTER(?population < 100000 ) # for places with huge population, use additional constraints for person1/person2 pair
  ?person1 wdt:P31 wd:Q5; #human
    wdt:P19 ?place_of_birth;
    wdt:P569 ?date_of_birth.
  ?person2 wdt:P31 wd:Q5; #human, empty P31 is also useful here
    wdt:P19 ?place_of_birth;
    wdt:P569 ?date_of_birth.
  FILTER(!(((DAY(?date_of_birth)) = 1 ) && ((MONTH(?date_of_birth)) = 1 ))) # I usually exclude January 1, too many false positives even with 1 day precision
  FILTER( ?person1 != ?person2)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "pt,es,[AUTO_LANGUAGE]". }
  }
  ORDER BY DESC(?date_of_birth)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?date_of_birth"):::projected v2("?person1"):::projected v3("?person2"):::projected v5("?place_of_birth"):::projected v4("?population") c13(["pt,es,#91;AUTO_LANGUAGE#93;"]):::literal c11(["bd:serviceParam"]):::iri c7(["wd:Q5"]):::iri c4(["wd:Q155"]):::iri f0[["?person1 != ?person2"]] f0 --> v2 f0 --> v3 f1[["not day-from-dateTime(?date_of_birth) = '1^^xsd:integer'month-from-dateTime(?date_of_birth) = '1^^xsd:integer'"]] f1 --> v1 f2[["?population < '100000^^xsd:integer'"]] f2 --> v4 v5 --"wdt:P17"--> c4 v5 --"wdt:P1082"--> v4 v2 --"wdt:P31"--> c7 v2 --"wdt:P19"--> v5 v2 --"wdt:P569"--> v1 v3 --"wdt:P31"--> c7 v3 --"wdt:P19"--> v5 v3 --"wdt:P569"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end