query-42e60f5f5a26bb66ad92fe00118de6f1

rq turtle/ttl

title: DOIs of works that are citing or cited by works one or both of two given topics PREFIX target1: http://www.wikidata.org/entity/Q21447895 PREFIX target2: http://www.wikidata.org/entity/Q2539

SELECT ?doi WITH { SELECT DISTINCT ?work WHERE { { ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31 / wdt:P279) ) target1: . } UNION { ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31 / wdt:P279) ) target2: . } } } AS %works WITH { SELECT (MAX(?dates) as ?datetime) ?work WHERE { INCLUDE %works ?work wdt:P921 ?topic . ?work wdt:P577 ?dates . } GROUP BY ?work } AS %result WHERE { INCLUDE %result # There is a problem with BC dates # BIND(xsd:date(?datetime) AS ?date) BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date) ?work wdt:P356 ?doi .
}

GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics

ORDER BY DESC(?date) LIMIT 200

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#title: DOIs of works that are citing or cited by works one or both of two given topics
PREFIX target1: <http://www.wikidata.org/entity/Q21447895>
PREFIX target2: <http://www.wikidata.org/entity/Q2539>

SELECT ?doi
WHERE {
   {
  SELECT (MAX(?dates) as ?datetime) ?work 
  WHERE {
     {
  SELECT DISTINCT ?work WHERE {
    { ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target1: . }
    UNION
    { ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target2: . }
  }
}    ?work wdt:P921 ?topic . 
    ?work wdt:P577 ?dates . 
  }
  GROUP BY ?work
}  # There is a problem with BC dates
  # BIND(xsd:date(?datetime) AS ?date)
  BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date)
  ?work wdt:P356 ?doi .    
}
# GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics
ORDER BY DESC(?date)
LIMIT 200

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?date") v4("?dates") v5("?datetime") v6("?doi"):::projected v3("?topic") v2("?work") a1((" ")) a2((" ")) a3((" ")) a4((" ")) c7([http://www.wikidata.org/entity/Q2539]):::iri c3([http://www.wikidata.org/entity/Q21447895]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P921"--> a3 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; a3 --"wdt:P31"--> a4 a4 --"wdt:P279"--> c7 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; a3 --"wdt:P1269"--> c7 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; a3 --"wdt:P361"--> c7 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P921"--> a1 subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; subgraph union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c3 end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P1269"--> c3 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P361"--> c3 end union3r <== or ==> union3l end end union0r <== or ==> union0l end v2 --"wdt:P921"--> v3 v2 --"wdt:P577"--> v4 bind1[/"max(?dates)"/] v4 --o bind1 bind1 --as--o v5 bind2[/"replace(str(?datetime),'T.*','')"/] v5 --o bind2 bind2 --as--o v6 v2 --"wdt:P356"--> v6