User:Vahurzpu/Queries

High schools in Virginia with coordinate location (P625) but no OpenStreetMap linksEdit

PREFIX osmt: <https://wiki.openstreetmap.org/wiki/Key:>
SELECT DISTINCT ?school WHERE {
  ?school wdt:P31 wd:Q9826.
  ?school wdt:P131* wd:Q1370.
  ?school wdt:P625 [].
  FILTER (!BOUND(?osmid)).
  SERVICE <https://sophox.org/sparql> {
    OPTIONAL {?osmid osmt:wikidata ?school}.
  }
}

Try it!

US laws where the United States Public Law (P3837) citation disagrees with legislated by (P467)Edit

SELECT ?law ?pl ?plterm ?normalterm WHERE 
{
  ?law wdt:P31 wd:Q476068.
  ?law wdt:P3837 ?pl.
  BIND (STRBEFORE(?pl, "-") as ?congstr).
  ?plterm p:P31 ?termprop.
  ?termprop ps:P31 wd:Q15238777.
  ?termprop pq:P642 wd:Q11268.
  ?termprop pq:P1545 ?congstr.
  ?law wdt:P467 ?normalterm.
  FILTER (?normalterm != ?plterm)
}

Try it!

Uncited dates of death for people who have NYT obituaries in WikidataEdit

SELECT ?subject ?subjectLabel ?obiturl WHERE 
{
  ?item wdt:P31 wd:Q309481.
  ?item wdt:P1433 wd:Q9684.
  ?item wdt:P953 ?obiturl.
  ?item wdt:P921 ?subject.
  ?subject p:P570 ?deathStatement.
  MINUS {?deathStatement wikibase:rank wikibase:DeprecatedRank}
  MINUS {?deathStatement prov:wasDerivedFrom []}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

People at Janelia Research Campus (Q1319362), along with their identifiers on the Janelia webpageEdit

SELECT ?qid_person ?janelia_person ?orcid
WHERE 
{
  ?item wdt:P1416 wd:Q1319362.
  OPTIONAL {?item wdt:P496 ?orcid.}
  ?item p:P1416 [prov:wasDerivedFrom [pr:P854 ?biourl]].
  BIND (STRAFTER(STR(?biourl), "/people/") AS ?janelia_person).
  BIND (STRAFTER(STR(?item), "/entity/") AS ?qid_person).
}

Try it!

People whose place of death (P20) is in a Nazi concentration camp (Q328468), but died outside the existence of Nazi Germany (Q7318)Edit

SELECT ?person ?personLabel ?deathday WHERE {
  wd:Q7318 wdt:P571 ?start.
  wd:Q7318 wdt:P576 ?end.
  ?person wdt:P570 ?deathday.
  ?person wdt:P20 ?camp.
  ?camp wdt:P31 wd:Q328468.
  FILTER (!((?deathday > ?start) && (?deathday < ?end))).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?deathday

Try it!

described at URL (P973) that is part of English Wikipedia (Q328)Edit

SELECT ?item ?itemLabel ?url WHERE {
  ?item wdt:P973 ?url.
  FILTER CONTAINS(STR(?url), "en.wikipedia").
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Advisors without Academic Tree ID (P2381) of students with the IDEdit

SELECT DISTINCT ?advisor ?advisorLabel WHERE 
{
  ?student wdt:P184 ?advisor.
  ?student wdt:P2381 [].
  MINUS {?advisor wdt:P2381 []}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Authors in the High Energy Physics category of arXiv (Q118398) without INSPIRE-HEP author ID (P2930)Edit

SELECT DISTINCT ?author ?authorLabel WHERE {
  ?paper wdt:P818 ?arxiv.
  FILTER STRSTARTS(?arxiv, "hep").
  ?paper wdt:P50 ?author.
  MINUS {?author wdt:P2930 []}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!


Approximate equivalent of the DNB No WP on WikisourceEdit

This query returns Wikisource pages where at least one of the main subjects is missing an English Wikipedia article. Right now this excludes DNB redirect pages; many of these are missing main subjects entirely.

SELECT ?subject ?subjectLabel ?ws WHERE 
{
  ?item wdt:P1433 wd:Q15987216.
  ?item wdt:P31 wd:Q19389637.
  ?ws schema:about ?item.
  ?item wdt:P921 ?subject.
  MINUS {
    ?wp schema:about ?subject.
    ?wp schema:isPartOf <https://en.wikipedia.org/>.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Get data about people based on items connected through Commons sitelinksEdit

I don't expect to reuse this query much, or maybe ever, but the pattern for "get the person, either directly or through their category" is useful on Commons generally. Also, while I didn't think of this earlier, it wouldn't be that hard to directly input sitelinks.

SELECT ?subject ?birth ?death ?commonscat ?creatorpage

WITH { 
  SELECT ?subject WHERE {  
    VALUES ?item {wd:Q332331 wd:Q449885 wd:Q6264333}
    {
      ?item wdt:P31 wd:Q5.
      BIND (?item AS ?subject).
    } UNION {
      ?item wdt:P301 ?subject.
    }
  }
} AS %subjects
  
WHERE {
  INCLUDE %subjects.
  OPTIONAL {?subject wdt:P569 ?birth.}
  OPTIONAL {?subject wdt:P570 ?death.}
  OPTIONAL {?subject wdt:P373 ?commonscat.}
  OPTIONAL {?subject wdt:P1472 ?creatorpage.}
}

Try it!