query-41fbc374ec38361d3979fdf8ec4dad16

rq turtle/ttl

?item1 is the imported one

?item2 is human and sitelink to ruwiki

?item1 and ?item2 are born the same date

SELECT DISTINCT ?item1 ?label_en ?birthyear ?deathyear ?item2 ?label_ru WITH { SELECT ?item1 ?FAST_ID ?label_en WHERE { #VALUES ?item1 { wd:??? } . ?item1 p:P214 [ps:P214 ?viaf ; prov:wasDerivedFrom [pr:P248 wd:Q3294867] ] . ?item1 rdfs:label ?label_en . FILTER(LANG(?label_en) = "en") FILTER(CONTAINS(?label_en,"vich")) } #LIMIT 20 } AS %get_humans_with_FAST_ID WHERE { INCLUDE %get_humans_with_FAST_ID ?item1 wdt:P569 ?birth. ?item2 wdt:P569 ?birth. BIND(str(YEAR(?birth)) AS ?birthyear) ?item1 wdt:P570 ?death. ?item2 wdt:P570 ?death. BIND(str(YEAR(?death)) AS ?deathyear) FILTER (?item1 != ?item2) ?item2 wdt:P31 wd:Q5. ?ruwiki_sitelink schema:about ?item2 . ?ruwiki_sitelink schema:isPartOf https://ru.wikipedia.org/. { ?item2 wdt:P27 wd:Q159. } UNION { ?item2 wdt:P27 wd:Q15180 . } UNION { ?item2 wdt:P27 wd:Q34266 . } ?item2 rdfs:label ?label_ru. FILTER (LANG(?label_ru) = "ru") } ORDER BY ?label_en ?label_ru

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
# ?item1 is the imported one
# ?item2 is human and sitelink to ruwiki
# ?item1 and ?item2 are born the same date
SELECT DISTINCT ?item1 ?label_en ?birthyear ?deathyear ?item2 ?label_ru
WHERE
{

{
  SELECT ?item1 ?FAST_ID ?label_en
  WHERE
  {
    #VALUES ?item1 { wd:??? } .
    ?item1 p:P214 [ps:P214 ?viaf ; prov:wasDerivedFrom [pr:P248 wd:Q3294867] ] .
    ?item1 rdfs:label ?label_en .
    FILTER(LANG(?label_en) = "en")
    FILTER(CONTAINS(?label_en,"vich"))
  }
  #LIMIT 20
}  ?item1 wdt:P569 ?birth.
  ?item2 wdt:P569 ?birth.
  BIND(str(YEAR(?birth)) AS ?birthyear)
  ?item1 wdt:P570 ?death.
  ?item2 wdt:P570 ?death.
  BIND(str(YEAR(?death)) AS ?deathyear)
  FILTER (?item1 != ?item2)
  ?item2 wdt:P31 wd:Q5.
  ?ruwiki_sitelink schema:about ?item2 .
  ?ruwiki_sitelink schema:isPartOf <https://ru.wikipedia.org/>.
  { ?item2 wdt:P27 wd:Q159. } UNION { ?item2 wdt:P27 wd:Q15180 . } UNION { ?item2 wdt:P27 wd:Q34266 . }
  ?item2 rdfs:label ?label_ru.
  FILTER (LANG(?label_ru) = "ru")
}
ORDER BY ?label_en ?label_ru

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?birth") v7("?birthyear"):::projected v8("?death") v9("?deathyear"):::projected v3("?item1"):::projected v4("?item2"):::projected v1("?label_en"):::projected v2("?label_ru"):::projected v10("?ruwiki_sitelink") v5("?viaf") a1((" ")) a2((" ")) c19(["wd:Q15180"]):::iri c18(["wd:Q159"]):::iri c20(["wd:Q34266"]):::iri c6(["wd:Q3294867"]):::iri c16([https://ru.wikipedia.org/]):::iri c13(["wd:Q5"]):::iri f0[["?label_ru = 'ru'"]] f0 --> v2 f1[["?item1 != ?item2"]] f1 --> v3 f1 --> v4 f2[["contains(?label_en,'vich')"]] f2 --> v1 f3[["?label_en = 'en'"]] f3 --> v1 a1 --"p:statement/P214"--> v5 a2 --"p:reference/P248"--> c6 a1 --"prov:wasDerivedFrom"--> a2 v3 --"p:P214"--> a1 v3 --"rdfs:label"--> v1 v3 --"p:direct/P569"--> v6 v4 --"p:direct/P569"--> v6 bind4[/"str(year-from-dateTime(?birth))"/] v6 --o bind4 bind4 --as--o v7 v3 --"p:direct/P570"--> v8 v4 --"p:direct/P570"--> v8 bind5[/"str(year-from-dateTime(?death))"/] v8 --o bind5 bind5 --as--o v9 v4 --"p:direct/P31"--> c13 v10 --"schema:about"--> v4 v10 --"schema:isPartOf"--> c16 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; v4 --"p:direct/P27"--> c20 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P27"--> c19 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P27"--> c18 end union0r <== or ==> union0l end v4 --"rdfs:label"--> v2