User:MartinPoulter/queries

For many more examples of these queries, see Wikidata:SPARQL query service/queries/examples and Wikidata:SPARQL_query_service/queries. For a tutorial, see User:TweetsFactsAndQueries/A Guide To WDQS. For biomedical query examples, see [1].

Also of interest: mw:Help:Extension:Kartographer

Note to self: Wikidata API can be used to get all properties for up to 50 items at once, e.g. https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q64%7CQ567&format=json

Counting stuff on Wikidata edit

Go to Wikidata:Statistics for counts of people, organizations, occurrences etc.

All Wikidata properties with label and description, ordered numerically edit

Adapted from one of the Query Service Examples

#title:Wikidata properties in numerical order
SELECT ?property ?propertyType ?propertyLabel ?propertyDescription WHERE {
  ?property wikibase:propertyType ?propertyType .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ASC(xsd:integer(STRAFTER(STR(?property), 'P')))
Wikidata properties in numerical order

Variation of the above excluding external IDs (thanks Magnus Sälgö) edit

#title:Wikidata properties excluding external IDs
SELECT ?id ?idLabel ?idDescription ?new{
  ?id wikibase:directClaim ?pid .
 minus{?id wikibase:propertyType wikibase:ExternalId}
  BIND(Replace(STR(?id),"http://www.wikidata.org/entity/P"," ") as ?new)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY DESC(xsd:integer(?new))
Wikidata properties excluding external IDs

Count of scientific articles edit

SELECT (COUNT(?article) AS ?count)
WHERE {
?article wdt:P31/wdt:P279* wd:Q13442814
}
Try it!

Count of fictional characters edit

#title:Count of fictional characters
SELECT (COUNT(DISTINCT ?article) AS ?count)
WHERE {?article wdt:P31/wdt:P279* wd:Q95074}
Count of fictional characters

Count of items with coordinate locations edit

#title:Count of items with coordinate locations
SELECT (COUNT(?item) AS ?count)
WHERE { ?item wdt:P625 [] }
Count of items with coordinate locations

Count of organisations edit

#title:Count of organizations
SELECT (COUNT(DISTINCT ?obj) AS ?count) WHERE {
?obj wdt:P31/wdt:P279* wd:Q43229
}
Count of organizations

Count of labels for a given item, broken down by language edit

#title:Number of labels for an item, split by language
SELECT ?q ?langcode ?langLabel (COUNT(?label) AS ?count) WHERE {
VALUES ?q {wd:Q43459}
  ?q (rdfs:label|skos:altLabel) ?label
  BIND(LANG(?label) AS ?langcode)
  ?lang wdt:P218 ?langcode 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?q ?langcode ?langLabel
ORDER BY DESC(?count)
Number of labels for an item, split by language

Women born in the UK edit

SELECT DISTINCT ?p ?pLabel ?pDescription WHERE {
?p wdt:P31 wd:Q5;
   wdt:P21 wd:Q6581072;
{?p wdt:P19 wd:Q145} # place of birth: UK
  UNION {?p wdt:P19 ?place.
         { ?place wdt:P131?/wdt:P17 wd:Q145 } # places whose country is the UK
         UNION
         { ?place wdt:P131*/wdt:P17?/wdt:P31 wd:Q3336843 } # places whose country is a constituent of the UK
 }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?pLabel
Try it!

Women with place of birth: UK edit

SELECT DISTINCT ?p ?pLabel ?pDescription WHERE {
?p wdt:P31 wd:Q5;
   wdt:P21 wd:Q6581072;
   wdt:P19 wd:Q145.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?pLabel
Try it!

Voltaire edit

Wikipedia articles about works edit

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID
    SELECT ?work ?title ?year ?english ?french WHERE {
      ?work wdt:P50 wd:Q9068
    OPTIONAL{?work wdt:P577 ?pubdate}
    BIND(YEAR(?pubdate) as ?year)
    OPTIONAL{ ?english schema:about ?work ; schema:isPartOf <https://en.wikipedia.org/> }
    OPTIONAL{ ?french schema:about ?work ; schema:isPartOf <https://fr.wikipedia.org/> }
    #OPTIONAL{ ?german schema:about ?work ; schema:isPartOf <https://de.wikipedia.org/> }
    OPTIONAL{ ?work rdfs:label ?title filter(lang(?title) = "en") }
    }
    

Categorised timeline of works edit

This query was improved by Navino Evans.

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, image (P18)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID
    SELECT ?workLabel ?pubdate ?pubdatePrecision ?image ?typelabel ?english  
    (URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", SUBSTR(STR(?work),32) )) as ?reasonator) #build a reasonator link
    (IF(BOUND(?english), ?english, ?reasonator) as ?link) # link to English Wikipedia article, if available
    WHERE {
    ?work wdt:P50 wd:Q9068; # author: Voltaire
       wdt:P31 ?type; # What is the work? poem, play, historical work etc.? 
       p:P577/psv:P577 ?pubdateStatementNode
    MINUS {?work wdt:P31 wd:Q3331189} # exclude editions
    MINUS {?work wdt:P31 wd:Q105420} # exclude anthologies
    ?pubdateStatementNode wikibase:timeValue ?pubdate ;
       wikibase:timePrecision ?pubdatePrecision # get precision of the publication date
    OPTIONAL {?work wdt:P18 ?image}
    OPTIONAL{ ?english schema:about ?work ; schema:isPartOf <https://en.wikipedia.org/> }
    SERVICE wikibase:label {bd:serviceParam wikibase:language "fr,en,de"} # Prefer labels in French but fall back to English and German
    ?type rdfs:label ?typelabel FILTER(lang(?typelabel) ="en") # English labels for the types
    }
    

Works ordered by how many language versions of Wikipedia have an article about them edit

SELECT ?work ?workLabel (COUNT(DISTINCT ?sitelink) as ?linkcount) WHERE {
  ?work wdt:P50 wd:Q9068.  # works by Voltaire
MINUS {?work wdt:P31 wd:Q39811647} # translations
MINUS {?work wdt:P31 wd:Q3331189} # editions
MINUS {?work wdt:P31 wd:Q105420} # anthologies
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,de". }
OPTIONAL{?sitelink schema:about ?work . # get Wikimedia pages about the work
FILTER(CONTAINS(str(?sitelink), ".wikipedia.org/")) } # only Wikipedia links
} GROUP BY ?work ?workLabel ORDER BY DESC(?linkcount)
Try it!

Economics edit

Birthplaces of economists edit

On 28 April 2016:

  • 2062 found for occupation:economist
  • 4997 found for occupation:economist or field:economics
  • 4969 found for occupation:economist or field:economics minus double-counting. DISTINCT had no effect. Still some duplicate rows due to some places having multiple co-ordinates

03 June 2016:

  • 6868 results. No change in the query explains the extra couple of thousand. Just more data?

02 November 2016:

  • 8832 results.

The map was getting frustratingly slow, and sometimes timing out, so I've split it into two.

Dead edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide": ["?coord", "?layer"]}
SELECT DISTINCT ?person ?name ?birthplace ?birthyear ?coord ?layer WHERE {
   {?person wdt:P106 wd:Q188094} UNION {?person wdt:P101 wd:Q8134} MINUS {?person wdt:P106 wd:Q188094; wdt:P101 wd:Q8134}
   ?person wdt:P570 ?dod;
     wdt:P19 ?place .
   ?place wdt:P625 ?coord
   OPTIONAL { ?person wdt:P569 ?dob }
   BIND(YEAR(?dob) as ?birthyear)
  BIND(IF( (?birthyear < 1700), "Pre-1700", IF((?birthyear < 1751), "1700-1750", IF((?birthyear < 1801), "1751-1800", IF((?birthyear < 1851), "1801-1850", IF((?birthyear < 1901), "1851-1900", IF((?birthyear < 1951), "1901-1950", "Post-1950") ) ) ) )) AS ?layer )
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".?person rdfs:label ?name. ?place rdfs:label ?birthplace }
} ORDER BY ?birthyear

Living edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide": ["?coord"]}
SELECT ?coord ?birthyear ?birthplace ?name ?person WHERE {
   {?person wdt:P106 wd:Q188094 } UNION {?person wdt:P101 wd:Q8134} MINUS {?person wdt:P106 wd:Q188094; wdt:P101 wd:Q8134}
   ?person wdt:P19 ?place .
   ?place wdt:P625 ?coord .
   OPTIONAL { ?person wdt:P569 ?dob }.
   MINUS { ?person wdt:P570 ?dod }.
   BIND(YEAR(?dob) as ?birthyear).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?person rdfs:label ?name. ?place rdfs:label ?birthplace}
}

Economics Nobel Laureates' workplace location, with Wikipedia links edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide": ["?coord"]}
SELECT ?name ?coord ?image ?workplace ?article WHERE {
?person wdt:P166 wd:Q47170 ;
     wdt:P108 ?place .
?place wdt:P625 ?coord
OPTIONAL{ ?person wdt:P18 ?image }
OPTIONAL{ ?article schema:about ?person ; schema:isPartOf <https://en.wikipedia.org/> }
MINUS{ ?person wdt:P31/wdt:P279? wd:Q15632617 } # exclude fictional people
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?place rdfs:label ?workplace. ?person rdfs:label ?name}
}

Economics Nobel Laureates' alma mater location edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide": ["?coord"]}
SELECT ?name ?coord ?image ?almamater ?article WHERE {
?person wdt:P166 wd:Q47170 ;
        wdt:P69 ?place .
?place wdt:P625 ?coord
OPTIONAL{ ?person wdt:P18 ?image }
OPTIONAL{ ?article schema:about ?person ; schema:isPartOf <https://en.wikipedia.org/> }
MINUS{ ?person wdt:P31/wdt:P279? wd:Q15632617 } # Exclude fictional people
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?place rdfs:label ?almamater. ?person rdfs:label ?name}
}

Specialisms within economics and related nationalities edit

The following query uses these:

  • Properties: field of work (P101)  View with Reasonator View with SQID, country of citizenship (P27)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT ?person ?name ?field ?fieldname ?nationality WHERE {
       ?person wdt:P101 ?field; #?field = Q39680 for macroeconomics # Q39072 for microeconomics
         wdt:P27 ?place .
       ?field wdt:P279+ wd:Q8134 .
       ?person rdfs:label ?name filter (lang(?name) = "en")
       ?place rdfs:label ?nationality filter (lang(?nationality) = "en")
       ?field rdfs:label ?fieldname filter (lang(?fieldname) = "en")
    MINUS{ ?person wdt:P31/wdt:P279? wd:Q15632617 } # exclude fictional people
    } ORDER BY ASC(?fieldname)
    

Only four with field:macroeconomics One with field:microeconomics

Economists with a Project Gutenberg ID and optionally an English Wikisource profile edit

The following query uses these:

  • Properties: occupation (P106)  View with Reasonator View with SQID, field of work (P101)  View with Reasonator View with SQID, Project Gutenberg author ID (P1938)  View with Reasonator View with SQID, Online Books Page author ID (P4629)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?name ?birthyear ?deathyear ?enws ?quotes ?commonscat
    (URI(CONCAT("https://www.gutenberg.org/ebooks/author/", ?gutenberg_id)) AS ?gutenberg) 
    (URI(CONCAT("https://doi.org/10.1093/ref:odnb/", ?odnb)) AS ?odnburl)
    (URI(CONCAT("http://onlinebooks.library.upenn.edu/webbin/book/lookupname?key=", ?books)) AS ?booksurl)
    (URI(CONCAT("https://www.britannica.com/", ?britannica)) AS ?britannicaurl) ?npg WHERE {
    { ?person wdt:P106 wd:Q188094 }
    UNION
    { ?person wdt:P101 wd:Q8134 }
    OPTIONAL {?person wdt:P1938 ?gutenberg_id}
    OPTIONAL { ?person wdt:P4629 ?books }
    OPTIONAL {
      ?enws schema:about ?person;
      schema:isPartOf <https://en.wikisource.org/>
    }
    FILTER (BOUND(?enws)
    

Economics awards and their recipients, by year edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID, point in time (P585)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?personLabel ?award ?awardLabel ?year WHERE {
      ?person p:P166 ?statement.
      ?statement ps:P166 ?award.
      ?award wdt:P31 wd:Q17701409 
      OPTIONAL { ?statement pq:P585 ?date. BIND(YEAR(?date) AS ?year) }
    MINUS{ ?person wdt:P31/wdt:P279? wd:Q15632617 } # exclude fictional people
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ASC(?awardLabel) ASC(?year)
    

Winners of multiple economics awards edit

The following query uses these:

  • Properties: award received (P166)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?personLabel (COUNT(?award) AS ?awards) (GROUP_CONCAT(?awardLabel; separator=", ") as ?list) WHERE {
      ?person wdt:P166 ?award.
      ?award wdt:P31 wd:Q17701409 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . ?award rdfs:label ?awardLabel . ?person rdfs:label ?personLabel }
    } GROUP BY ?person ?personLabel
    HAVING ( ?awards > 1 )
    ORDER BY DESC(?awards)
    

People who won economics awards but are not listed as economists edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID, point in time (P585)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?personLabel ?award ?awardLabel ?year WHERE {
      ?person p:P166 ?statement.
      ?statement ps:P166 ?award.
      ?award wdt:P31 wd:Q17701409 
      MINUS { ?person wdt:P106 wd:Q188094 }
    MINUS{ ?person wdt:P31/wdt:P279? wd:Q15632617 } # exclude fictional people
      OPTIONAL { ?statement pq:P585 ?date. BIND(YEAR(?date) AS ?year) }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ASC(?awardLabel) ASC(?year)
    

Wikidata graph: fields of economics edit

Titles of (current) national finance ministers edit

The following query uses these:

Timeline of Chancellors of the Exchequer edit

#title:Chancellors of the Exchequer and time served in office
SELECT ?item ?itemLabel ?start ?end ?image ?link ?partyLabel WHERE {
  ?item p:P39 ?s.?s ps:P39 wd:Q531471.
  ?s pq:P580 ?start. OPTIONAL {?s pq:P582 ?end}
  OPTIONAL {?item wdt:P18 ?image}
  OPTIONAL {?item wdt:P1417 ?id}
  OPTIONAL {?item wdt:P102 ?party}
  BIND(IF(BOUND(?id), URI(CONCAT("https://www.britannica.com/",?id)) , ?item) AS ?link)
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?start
Chancellors of the Exchequer and time served in office

This query as a Histropedia timeline

Timeline of Chairs of the US Federal Reserve edit

#title:Chairs of the US Federal Reserve and time spent in office
SELECT ?item ?itemLabel ?start ?end ?image ?link ?nominatedLabel WHERE {
  ?item p:P39 ?s.?s ps:P39 wd:Q2666591.
  ?s pq:P580 ?start. OPTIONAL {?s pq:P582 ?end}
  OPTIONAL {?item wdt:P18 ?image}
  OPTIONAL {?item wdt:P1417 ?id}
  OPTIONAL {?s pq:P4353 ?nominated}
  BIND(IF(BOUND(?id), URI(CONCAT("https://www.britannica.com/",?id)) , ?item) AS ?link)
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?start
Chairs of the US Federal Reserve and time spent in office

This query as a Histropedia timeline

Free trade areas edit

SELECT ?c ?cLabel ?item ?itemLabel WHERE {
?item wdt:P31 wd:Q5335686.
?c wdt:P463 ?item
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?itemLabel
Try it!

Not Economics edit

Stars in flag versus fertility edit

SELECT ?iso ?countryLabel (SUM(?stars) as ?stars) ?fertility WHERE {
{SELECT DISTINCT ?country ?iso WHERE {
VALUES ?countrytypes {wd:Q6256 wd:Q3624078} # country and sovereign state
?country wdt:P31 ?countrytypes ; wdt:P298 ?iso
MINUS {?country wdt:P576 []} # Not dissolved
}  }
?country wdt:P163 ?flag.
OPTIONAL{
?flag p:P180 [ps:P180 ?feature ; pq:P1114 ?stars] . # quantity of feature
?feature wdt:P279? wd:Q836708  # type of star polygon
}
OPTIONAL { ?country wdt:P4841 ?fertility }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?iso ?countryLabel ?fertility
ORDER BY DESC(?stars) ?countryLabel
Try it!

University of Oxford edit

Colleges and Permanent Private Halls with coats of arms and official web sites edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide": ["?location"]}
SELECT DISTINCT ?web ?collegeLabel (IF(BOUND(?hq), ?hq, ?coord) as ?location) ?arms WHERE {
  {?college wdt:P31 wd:Q2581649} UNION {?college wdt:P31 wd:Q3338504}
  MINUS {?college wdt:P576 []}
  OPTIONAL { ?college p:P159/pq:P625 ?hq }
  OPTIONAL { ?college wdt:P625 ?coord }
 ?college wdt:P94 ?arms;
          wdt:P856 ?web
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

How many Wikidata entities were educated at the University of Oxford? edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID
    SELECT (COUNT(?alum) AS ?count)
    WHERE
    {
    	?alum wdt:P69 wd:Q34433. 
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Notable people educated at colleges of the University of Oxford edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, educated at (P69)  View with Reasonator View with SQID
    SELECT ?college ?collegeLabel (COUNT(DISTINCT ?alum) AS ?count)
    WHERE {
    {?college wdt:P31 wd:Q2581649} UNION {?college wdt:P31 wd:Q3338504}. # college or private hall
    ?alum wdt:P69 ?college.
    MINUS { ?alum wdt:P31 wd:Q15632617 } # Exclude fictional people
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                            ?college rdfs:label ?collegeLabel }
    } GROUP BY ?college ?collegeLabel
    ORDER BY DESC(?count)
    

How many Wikidata entities were educated at the University of Oxford or at individual colleges? edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT (COUNT(?alum) AS ?count)
    WHERE {
    	{ ?alum wdt:P69 wd:Q34433 }
    UNION { ?alum wdt:P69/wdt:P31 wd:Q2581649 }
    }
    

Which of the above are fictional humans? edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, educated at (P69)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?alumDescription ?college ?collegeLabel
    WHERE {
    	?alum wdt:P31 wd:Q15632617
    {?alum wdt:P69 wd:Q34433 }
    UNION {?college wdt:P31 wd:Q2581649.
            ?alum wdt:P69 ?college}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Organisations founded by Oxford alumni (including colleges) edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, founded by (P112)  View with Reasonator View with SQID
    SELECT DISTINCT ?alum ?alumLabel ?collegeLabel ?org ?orgLabel
    WHERE {
    	{?alum wdt:P69 wd:Q34433 }
    UNION { {?college wdt:P31 wd:Q2581649} UNION {?college wdt:P31 wd:Q3338504}.
            ?alum wdt:P69 ?college.}
            ?org wdt:P112 ?alum.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ASC(?alumLabel)
    

Female graduates of Pembroke College edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, sex or gender (P21)  View with Reasonator View with SQID, educated at (P69)  View with Reasonator View with SQID
    SELECT ?person ?personLabel ?personDescription ?englishwp WHERE {
    ?person wdt:P31 wd:Q5; # human
            wdt:P21 wd:Q6581072; # sex or gender: female
            wdt:P69 wd:Q82606. # Educated at Pembroke College, Oxford
    OPTIONAL {?englishwp schema:about ?person; schema:isPartOf <https://en.wikipedia.org/> } # English Wikipedia page
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    } ORDER BY ?personLabel
    

Awards won by international female Oxford alumni (including colleges) edit

The following query uses these:

Image grid of international female Oxford alumnae edit

#defaultView:ImageGrid{"hide":["?image"]}
SELECT DISTINCT ?alum ?alumLabel ?alumDescription ?image
WHERE {
	{?alum wdt:P69 wd:Q34433 .}
UNION {?college wdt:P31 wd:Q2581649.
        ?alum wdt:P69 ?college.}
        ?alum wdt:P21 wd:Q6581072 .
       MINUS { ?alum wdt:P27 wd:Q145 }.
    OPTIONAL {?alum wdt:P18 ?image }.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

Things discovered by Oxford alumni (including colleges & PP halls) edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, discoverer or inventor (P61)  View with Reasonator View with SQID
    SELECT DISTINCT ?alum ?alumLabel ?collegeLabel ?discovered ?discoveredLabel
    WHERE {
    	{?alum wdt:P69 wd:Q34433 }
    UNION { { ?college wdt:P31 wd:Q2581649 } UNION { ?college wdt:P31 wd:Q3338504 }
            ?alum wdt:P69 ?college }
            ?discovered wdt:P61 ?alum
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ASC( ?alumLabel )
    

Recipients of the Bodley Medal edit

The following query uses these:

  • Properties: award received (P166)  View with Reasonator View with SQID
    SELECT ?winner ?winnerLabel ?winnerDescription
    WHERE {
    	?winner wdt:P166 wd:Q4936657.
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Recent publications by living staff (or former staff) of the University of Oxford edit

The following query uses these:

  • Properties: employer (P108)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, date of death (P570)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID
    SELECT DISTINCT ?authorLabel ?publication ?publicationLabel ?date 
    WHERE {
          { ?author wdt:P108 wd:Q34433 } # Listed as employees of the university
    UNION { {?college wdt:P31 wd:Q2581649 } UNION { ?college wdt:P31 wd:Q3338504 }.
            ?author wdt:P108 ?college } # Listed as employees of a college or hall
            MINUS{ ?author wdt:P570 ?date } # No death date
            ?publication wdt:P50 ?author 
    	OPTIONAL { ?publication wdt:P577 ?date }
      
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY DESC(?date)
    

Map of things in Oxford colour-coded by type edit

#defaultView:Map{"hide": ["?location"]}
SELECT ?place ?placeLabel (SAMPLE(?loc) AS ?location) ?layer WHERE {
?place wdt:P131 wd:Q34217;
       wdt:P31 ?type.
MINUS { ?place wdt:P576 [] } # Not closed down
OPTIONAL { ?place wdt:P625 ?coords }
OPTIONAL { ?place p:P159/pq:P625 ?hqcoords }
BIND (IF (BOUND(?coords), ?coords, ?hqcoords) AS ?loc)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?type rdfs:label ?layer.?place rdfs:label ?placeLabel }
} GROUP BY ?place ?placeLabel ?layer
Try it!

Map of things in Oxford and what they are named after edit

#defaultView:Map{"hide": ["?location"]}
SELECT ?person ?personLabel (SAMPLE(?img) AS ?image) (SAMPLE(?loc) AS ?location) ?placeLabel WHERE {
?place wdt:P131 wd:Q34217;
       wdt:P138 ?person FILTER (?person != wd:Q34217).
OPTIONAL { ?place wdt:P625 ?coords }
OPTIONAL { ?place p:P159/pq:P625 ?hqcoords }
BIND (IF (BOUND(?coords), ?coords, ?hqcoords) AS ?loc)
OPTIONAL { ?person wdt:P18 ?img }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?person ?personLabel ?placeLabel
Try it!

English Wikisource edit

People with ENWS author profiles edit

SELECT ?person ?enws WHERE {
?person wdt:P31 wd:Q5.
?enws schema:about ?person;
schema:isPartOf <https://en.wikisource.org/> FILTER CONTAINS(STR(?enws), "Author:")
} ORDER BY ?enws
Try it!

Bodleian Libraries collections edit

See also commons:Category:Bodleian_Library_manuscripts and w:en:Category:Bodleian_Library_collection

Things in collections of the Bodleian edit

The following query uses these:

  • Properties: collection (P195)  View with Reasonator View with SQID, inventory number (P217)  View with Reasonator View with SQID, inception (P571)  View with Reasonator View with SQID, language of work or name (P407)  View with Reasonator View with SQID
    SELECT DISTINCT ?thing ?thingLabel (GROUP_CONCAT(DISTINCT ?year; separator=", ") as ?years) ?shelfmark (GROUP_CONCAT(DISTINCT ?langLabel ; separator=", ") as ?languages) WHERE {
    { ?thing wdt:P195 wd:Q82133} UNION { ?thing p:P217/pq:P195 wd:Q82133 } #wd:Q16147979 
    OPTIONAL {?thing wdt:P217 ?shelfmark}
    OPTIONAL {?thing wdt:P571 ?date. BIND(YEAR(?date) AS ?year) }
    OPTIONAL {?thing wdt:P407 ?lang }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . ?thing rdfs:label ?thingLabel . ?lang rdfs:label ?langLabel }
    } GROUP BY ?thing ?thingLabel ?shelfmark
    ORDER BY ?thingLabel
    

Bodleian manuscripts, with images and Commons categories edit

The following query uses these:

  • Properties: collection (P195)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, image (P18)  View with Reasonator View with SQID, Commons category (P373)  View with Reasonator View with SQID, inventory number (P217)  View with Reasonator View with SQID
    SELECT DISTINCT ?thing ?thingLabel ?image (URI(CONCAT("https://commons.wikimedia.org/wiki/Category:",?cat) ) AS ?commons) WHERE {
    { ?thing wdt:P195 wd:Q82133 } UNION { ?thing p:P217/pq:P195 wd:Q82133 }
    { ?thing wdt:P31 wd:Q87167 } UNION { ?thing wdt:P31 wd:Q48498 }
    OPTIONAL { ?thing wdt:P18 ?image }
    OPTIONAL { ?thing wdt:P373 ?cat }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?thingLabel
    

University of Edinburgh edit

Notable people whose doctoral advisor was a University of Edinburgh alum (+ academic field) edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, doctoral advisor (P184)  View with Reasonator View with SQID, field of work (P101)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?supervisee ?superviseeLabel ?fieldLabel
    WHERE {
    	?alum wdt:P69 wd:Q160302. 
            ?supervisee wdt:P184 ?alum.
            OPTIONAL {?supervisee wdt:P101 ?field.}
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Awards won by women who attended the University of Edinburgh edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, sex or gender (P21)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?award ?awardLabel
    WHERE {
    ?alum wdt:P69 wd:Q160302; 
      wdt:P21 wd:Q6581072;
      wdt:P166 ?award.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Awards won by people employed by the University of Edinburgh edit

The following query uses these:

  • Properties: employer (P108)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?award ?awardLabel
    WHERE {
    ?alum wdt:P108 wd:Q160302; 
      wdt:P166 ?award.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Organisations founded by people born in Edinburgh edit

The following query uses these:

  • Properties: place of birth (P19)  View with Reasonator View with SQID, founded by (P112)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?org ?orgLabel
    WHERE
    {
    	?alum wdt:P19 wd:Q23436. 
            ?org wdt:P112 ?alum.
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

University of Bristol edit

Notable alumni of the University of Bristol whose citizenship is not UK edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, country of citizenship (P27)  View with Reasonator View with SQID
    SELECT ?nationality ?nationalityLabel ?alum ?alumLabel ?alumDescription
    WHERE {
    	?alum wdt:P69 wd:Q459506. 
           ?alum wdt:P27 ?nationality.
           MINUS { ?alum wdt:P27 wd:Q145 } 
           OPTIONAL { ?alum schema:description ?alumDescription FILTER (lang(?alumDescription) = "en").}
    	   OPTIONAL { ?alum rdfs:label ?alumLabel FILTER (lang(?alumLabel) = "en").}
      	   OPTIONAL { ?nationality rdfs:label ?nationalityLabel FILTER (lang(?nationalityLabel) = "en")}
    }
    ORDER BY ?nationalityLabel
    

Notable people whose doctoral advisor was a University of Bristol alum (+ academic field) edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, doctoral advisor (P184)  View with Reasonator View with SQID, field of work (P101)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?supervisee ?superviseeLabel ?fieldLabel
    WHERE
    {
    	?alum wdt:P69 wd:Q459506. 
            ?supervisee wdt:P184 ?alum.
            OPTIONAL {?supervisee wdt:P101 ?field.}
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Notable people whose doctoral advisor was a University of Bristol employee (+ academic field) edit

The following query uses these:

  • Properties: employer (P108)  View with Reasonator View with SQID, doctoral advisor (P184)  View with Reasonator View with SQID, field of work (P101)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?supervisee ?superviseeLabel ?fieldLabel
    WHERE
    {
    	?alum wdt:P108 wd:Q459506. 
            ?supervisee wdt:P184 ?alum.
            OPTIONAL {?supervisee wdt:P101 ?field.}
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Awards won by alumni of the University of Bristol edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?award ?awardLabel
    WHERE
    {
    	?alum wdt:P69 wd:Q459506. 
            ?alum wdt:P166 ?award.
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?awardLabel
    

Awards won by people employed by the University of Bristol (at some point in their career) edit

The following query uses these:

  • Properties: employer (P108)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?award ?awardLabel
    WHERE
    {
    	?alum wdt:P108 wd:Q459506. 
            ?alum wdt:P166 ?award.
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?awardLabel
    

University of Reading edit

Awards won by alumni of the University of Reading edit

The following query uses these:

  • Properties: educated at (P69)  View with Reasonator View with SQID, award received (P166)  View with Reasonator View with SQID
    SELECT ?alum ?alumLabel ?awardLabel WHERE {
      ?alum wdt:P69 wd:Q1432632 .
      ?alum wdt:P166 ?award .
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    } ORDER BY ?alumLabel
    

White Rose Research Online edit

Papers online at a White Rose URL but without "content deliverer: White Rose Research Online" qualifier edit

SELECT ?item ?itemLabel WHERE {
?item p:P953 ?s. ?s ps:P953 ?url FILTER (CONTAINS( STR(?url), "eprints.whiterose.ac.uk") )
MINUS {?s pq:P3274 wd:Q24753667 }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Papers by University of Leeds researchers with a Wikimedia-compatible licence edit

#title:scholarly papers by University of Leeds researchers in White Rose repository with a free licence
SELECT DISTINCT ?paper ?paperLabel ?licenceLabel ?fulltext WHERE {
  ?author wdt:P108 wd:Q503424.   # Employee of University of Leeds
  ?paper wdt:P31 wd:Q13442814; wdt:P50 ?author.   # scholarly article by this author
  VALUES ?freelicence {wd:Q6905323 wd:Q6905942}   # CC-BY or CC-BY-SA
  ?paper wdt:P275 ?licence . ?licence wdt:P629? ?freelicence.  # Article has this licence, or a specific edition such as CC-BY 3.0
  ?paper wdt:P953 ?fulltext FILTER(CONTAINS(STR(?fulltext), "whiterose.ac.uk"))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
} ORDER BY ?paper
scholarly papers by University of Leeds researchers in White Rose repository with a free licence

Universities of the UK edit

Map of universities edit

The following query uses these:

Museums edit

Museums with Twitter accounts edit

plus optional Instagram and Facebook

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, X username (P2002)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, Facebook username (P2013)  View with Reasonator View with SQID, Instagram username (P2003)  View with Reasonator View with SQID
    SELECT DISTINCT ?museum ?museumLabel ?countryLabel (URI(CONCAT("https://www.facebook.com/",?facebook)) AS ?facebooklink) (URI(CONCAT("https://www.instagram.com/",?instagram)) AS ?instagramlink) (URI(CONCAT("https://twitter.com/",?twitter)) AS ?twitterlink)
    WHERE {
    ?museum wdt:P31/wdt:P279* wd:Q33506;
      wdt:P2002 ?twitter.
    OPTIONAL { ?museum wdt:P17 ?country}
    OPTIONAL { ?museum wdt:P2013 ?facebook}
    OPTIONAL { ?museum wdt:P2003 ?instagram}
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,nl,fr,de,es,pt,bg,be,ru,hu,uk,ja"}
    } ORDER BY ?countryLabel ?museumLabel
    

Things that museums are named after edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, named after (P138)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID
    SELECT DISTINCT ?museum ?museumLabel ?countryLabel ?named ?namedLabel ?namedDescription
    WHERE {
    ?museum wdt:P31/wdt:P279* wd:Q33506;
      wdt:P138 ?named.
    OPTIONAL { ?museum wdt:P17 ?country}
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,nl,fr,de,es,pt,bg,be,ru,hu,uk,ja"}
    } ORDER BY ?countryLabel ?museumLabel
    

Global map of art museums, with their web sites edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT DISTINCT ?museum ?museumLabel ?coord ?image ?web
WHERE {
?museum wdt:P31 wd:Q207694;
   wdt:P625 ?coord .
OPTIONAL {?museum wdt:P18 ?image}.
OPTIONAL {?museum wdt:P856 ?web}.
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,nl,fr,de,es,pt"}
}

Map of museums in the UK, with images and web sites edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT DISTINCT ?web ?museum ?museumLabel (SAMPLE(?coord) AS ?coord) (SAMPLE(?image) AS ?image)
WHERE {
?museum wdt:P31/wdt:P279* wd:Q33506;
   wdt:P17 wd:Q145;
   wdt:P625 ?coord.
OPTIONAL {?museum wdt:P856 ?web}
OPTIONAL {?museum wdt:P18 ?image}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?web ?museum ?museumLabel

History of Science edit

Things that stars, galaxies, star clusters and nebulae are named after edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, named after (P138)  View with Reasonator View with SQID
    SELECT DISTINCT ?obj ?objLabel ?objDescription ?nom ?nomLabel ?nomDescription
    WHERE {
       {?obj wdt:P31/wdt:P279* wd:Q318} UNION {?obj wdt:P31/wdt:P279* wd:Q523}
      UNION {?obj wdt:P31/wdt:P279* wd:Q1054444}
      UNION {?obj wdt:P31/wdt:P279* wd:Q168845}
        ?obj wdt:P138 ?nom
       SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ASC(?objLabel)
    

Things that planets and their moons are named after edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, named after (P138)  View with Reasonator View with SQID, parent astronomical body (P397)  View with Reasonator View with SQID
    SELECT DISTINCT ?planet ?planetLabel ?planetDescription ?nom ?nomLabel ?nomDescription
    WHERE {
    	?planet wdt:P31/wdt:P279* wd:Q3132741 .
        ?planet wdt:P138 ?nom.
      ?planet wdt:P397 ?parent.
    	SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }.
    } ORDER BY DESC(?parent)
    

Things that spacecraft are named after edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, named after (P138)  View with Reasonator View with SQID
    SELECT DISTINCT ?obj ?objLabel ?objDescription ?nom ?nomLabel ?nomDescription
    WHERE {
    {?obj wdt:P31/wdt:P279* wd:Q40218} # type of spacecraft
    UNION {?obj wdt:P31/wdt:P279* wd:Q13226541}. # or spaceflight programme
        ?obj wdt:P138 ?nom #named after
       SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ASC(?objLabel)
    

Things that discovered stars edit

The following query uses these:

  • Properties: subclass of (P279)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, discoverer or inventor (P61)  View with Reasonator View with SQID
    SELECT ?discoverer ?discovererLabel  
    	(COUNT(DISTINCT ?star) as ?count)
    	(GROUP_CONCAT(DISTINCT(?starLabel); separator=", ") as ?stars)
    WHERE
    {
    	?ppart wdt:P279* wd:Q523 .
    	?star wdt:P31 ?ppart .
    	?star wdt:P61 ?discoverer .
    	SERVICE wikibase:label {
    		bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
    		?discoverer rdfs:label ?discovererLabel .
    		?star rdfs:label ?starLabel            
    	}
    }
    GROUP BY ?discoverer ?discovererLabel
    ORDER BY DESC(?count)
    

People who invented scientific instruments edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, discoverer or inventor (P61)  View with Reasonator View with SQID
    SELECT ?discoverer ?discovererLabel ?instrument ?instrumentLabel
    WHERE {
    	?instrument wdt:P31/wdt:P279* wd:Q3099911 ;
    	 wdt:P61 ?discoverer .
    	SERVICE wikibase:label {
    		bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Biosphere edit

See w:Wikipedia:WikiProject_United_Nations/Biosphere_Reserve_Descriptions

Map of Biosphere reserves with an entry and location in Wikidata but not in English Wikipedia edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT ?wikidata_item ?biosphere_reserve_name ?biosphereURL ?image ?location
  WHERE {
  ?wikidata_item wdt:P2520 ?biosphereURL ; # get a list of all biospheres
   wdt:P625 ?location # and location
  OPTIONAL{ ?wikidata_item wdt:P18 ?image }
FILTER NOT EXISTS { ?enwp schema:about ?wikidata_item ; schema:isPartOf <https://en.wikipedia.org/> } # No article in English wikipedia
   ?wikidata_item rdfs:label ?biosphere_reserve_name filter (lang(?biosphere_reserve_name) = "en")
}

Map of Biosphere reserves with an entry and location in Wikidata and an English Wikipedia article edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT ?wikidata_item ?biosphere_reserve_name ?biosphereURL ?wikipedia_article ?image ?location
  WHERE {
  ?wikidata_item wdt:P2520 ?biosphereURL ; # get a list of all biospheres
     wdt:P625 ?location # and location
  OPTIONAL{ ?wikidata_item wdt:P18 ?image }
?wikipedia_article schema:about ?wikidata_item ;
  schema:isPartOf <https://en.wikipedia.org/>. # Must have an article in English wikipedia
  ?wikidata_item rdfs:label ?biosphere_reserve_name filter (lang(?biosphere_reserve_name) = "en")
}

Biosphere reserves with an entry but no location edit

The following query uses these:

  • Properties: UNESCO Biosphere Reserve URL (P2520)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID
    SELECT ?wikidata_item ?biosphere_reserve_name ?biosphereURL
      WHERE {
      ?wikidata_item wdt:P2520 ?biosphereURL . # get a list of all biospheres
      FILTER NOT EXISTS { ?wikidata_item wdt:P625 ?location.} # no location
    
      ?wikidata_item rdfs:label ?biosphere_reserve_name filter (lang(?biosphere_reserve_name) = "en").
     }
    

Music edit

Lutenists ordered by year of birth edit

The following query uses these:

  • Properties: instrument (P1303)  View with Reasonator View with SQID, date of birth (P569)  View with Reasonator View with SQID, place of birth (P19)  View with Reasonator View with SQID
    SELECT ?player ?playerLabel ?article ?birthyear ?placeLabel
    WHERE {
      ?player wdt:P1303 wd:Q180733.
    OPTIONAL {?player wdt:P569 ?born}.
    OPTIONAL {?player wdt:P19 ?place}.
      BIND(YEAR(?born) as ?birthyear).
    OPTIONAL{ ?article schema:about ?player. ?article schema:isPartOf <https://en.wikipedia.org/>.  }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    ORDER BY ASC(?birthyear)
    

Artworks edit

Birthplaces of painters in the Rijksmuseum collection (based on query by Jane Darnell) edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT DISTINCT ?painter ?painterLabel ?birthplaceLabel ?geoloc where {
      ?painting wdt:P31/wdt:P279* wd:Q3305213 ;  # any painting (or type of painting)
       wdt:P195 wd:Q190804 ;  # in collection Rijksmuseum
       wdt:P170 ?painter . # get painter
      ?painter wdt:P19 ?birthplace . # get painter's birthplace
      ?birthplace wdt:P625 ?geoloc . #latitude and longitude
  SERVICE wikibase:label {
       bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,es"
    }
}

Image gallery of oil paintings from Rijksmuseum edit

The following query uses these:

Features: ImageGrid (Q24515278)  View with Reasonator View with SQID

#defaultView:ImageGrid
SELECT DISTINCT ?painting ?paintingLabel ?painterLabel ?image where {
      ?painting wdt:P31/wdt:P279* wd:Q3305213 ;  # any painting (or type of painting)
       wdt:P195 wd:Q190804 ;  # in collection Rijksmuseum
       wdt:P170 ?painter ; # get painter
       wdt:P186 wd:Q296955 ; # Made with oil paint
       wdt:P18 ?image . # Image from Commons of the artwork
  SERVICE wikibase:label {
       bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,es"
    }
} LIMIT 160

Visual art works by African-American women edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT ?person ?personLabel ?personimage ?work ?workLabel ?workimage WHERE {
  ?person wdt:P172 wd:Q49085 ;  # African American
  wdt:P21 wd:Q6581072 ;      # women
  wdt:P106/wdt:P279* wd:Q3391743 .  # visual artists
 OPTIONAL{ ?person wdt:P18 ?personimage }
  ?work wdt:P170 ?person . # and their work
 OPTIONAL{ ?work wdt:P18 ?workimage }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
  }

Trans people in the arts edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT DISTINCT ?person ?personLabel ?personimage ?field ?fieldLabel WHERE {
  {?person wdt:P21 wd:Q2449503 } UNION {?person wdt:P21 wd:Q1052281 }      # trans men and women
  ?person wdt:P106/wdt:P279* wd:Q483501 .  # artist
  ?person wdt:P106 ?field. 
  ?field wdt:P279* wd:Q483501
MINUS {?field wdt:P279* wd:Q33999} # not actors
         OPTIONAL{ ?person wdt:P18 ?personimage }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
  }

Art venues edit

Art venues in the UK, but not pubs edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide":["?coord"]}
SELECT DISTINCT ?item ?itemLabel ?url ?coord WHERE {
  VALUES ?type {wd:Q15090615 wd:Q7062022} # Arts venues + not-for-profit arts organisations
  ?item (wdt:P31/wdt:P279*) ?type. 
  ?item wdt:P17 wd:Q145. # in the UK
  MINUS {?item wdt:P31 wd:Q212198} # Exclude pubs
  OPTIONAL{?item wdt:P625 ?itemcoord}
  OPTIONAL {?item wdt:P131/wdt:P625 ?wherecoord}
  OPTIONAL {?item wdt:P856 ?url}
  BIND(IF(BOUND(?itemcoord), ?itemcoord, ?wherecoord) AS ?coord)
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
  }
}

All art exhibitions known to Wikidata edit

The following query uses these:

Poems edit

Note: poems are sometimes represented as instance of (P31) literary work (Q7725634); genre (P136) poem (Q5185279)

Poems from the 18th century, with their authors and languages edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID, inception (P571)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID, language of work or name (P407)  View with Reasonator View with SQID
    SELECT ?poem ?poemLabel ?languageLabel ?authorLabel ?year WHERE {
    ?poem wdt:P31/wdt:P279? wd:Q5185279;
    OPTIONAL{?poem wdt:P577 ?pubdate}
    OPTIONAL{?poem wdt:P571 ?inception}
    OPTIONAL{?poem wdt:P50 ?author}
    OPTIONAL{?poem wdt:P407 ?language}
    BIND((IF (BOUND(?pubdate),?pubdate,?inception) ) AS ?date)
    BIND(YEAR(?date) AS ?year)
    FILTER (?year > 1699 && ?year < 1800)
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru"}
    } ORDER BY ?authorLabel ?year ?poemLabel
    

Poems whose text is available online through Wikisource, or elsewhere edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID, full work available at URL (P953)  View with Reasonator View with SQID
    SELECT DISTINCT ?poem ?poemLabel ?authorLabel ?link WHERE {
    ?poem wdt:P31/wdt:P279? wd:Q5185279;
    OPTIONAL{?poem wdt:P50 ?author}
    OPTIONAL{?poem wdt:P953 ?text}
    OPTIONAL{?wikisource schema:about ?poem; schema:isPartOf <https://en.wikisource.org/>}
    BIND((IF (BOUND(?text),?text,?wikisource) ) AS ?link)
    FILTER BOUND(?link)
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru"}
    } ORDER BY ?authorLabel
    
  • 875 results as of 23 March 2017
  • 1430 results as of 17 October 2018

TODO: add links to text of volumes that a poem is published in.

Poets of the Kingdom of Great Britain whose birth and death years are known edit

The following query uses these:

  • Properties: occupation (P106)  View with Reasonator View with SQID, country of citizenship (P27)  View with Reasonator View with SQID, date of birth (P569)  View with Reasonator View with SQID, date of death (P570)  View with Reasonator View with SQID, VIAF ID (P214)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?personLabel (URI(CONCAT("http://viaf.org/viaf/",?viaf)) AS ?viaf_id) ?birthyear ?deathyear WHERE {
    ?person wdt:P106 wd:Q49757;
            wdt:P27 wd:Q161885;
            wdt:P569 ?birthdate;
            wdt:P570 ?deathdate.
    FILTER (!isBLANK(?birthdate))
    FILTER (!isBLANK(?deathdate))
    OPTIONAL{ ?person wdt:P214 ?viaf}
    BIND(YEAR(?birthdate) AS ?birthyear)
    BIND(YEAR(?deathdate) AS ?deathyear)
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru"}
    } ORDER BY ?birthyear
    

People who wrote a notable poem but do not have "poet" included in their occupations edit

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID
    SELECT DISTINCT ?work ?workLabel ?author ?authorLabel ?article WHERE {
    ?work wdt:P50 ?author ;
           wdt:P31/wdt:P279? wd:Q5185279. # ?work is a poem
    ?article schema:about ?work;
    	schema:isPartOf <https://en.wikipedia.org/> .
    MINUS {?author wdt:P106 wd:Q49757} # ?author is not listed as a poet
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?authorLabel
    

Notable works (with an English Wikipedia article) by authors who have no notable works edit

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID, notable work (P800)  View with Reasonator View with SQID
    SELECT DISTINCT ?work ?workLabel ?author ?authorLabel ?article WHERE {
    ?work wdt:P50 ?author .
    ?article schema:about ?work;
    	schema:isPartOf <https://en.wikipedia.org/> .
    ?author wdt:P106 wd:Q49757
    MINUS {?author wdt:P800 []}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?authorLabel
    

Works of Florence Earle Coates edit

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID, first line (P1922)  View with Reasonator View with SQID
    SELECT ?work ?title ?firstline ?year ?enws ?enwp WHERE {
      ?work wdt:P50 wd:Q5460603
    OPTIONAL{?work wdt:P577 ?pubdate}
    OPTIONAL{?work wdt:P1922 ?firstline}
    BIND(YEAR(?pubdate) as ?year)
    OPTIONAL{ ?enws schema:about ?work ; schema:isPartOf <https://en.wikisource.org/> }
    OPTIONAL{ ?enwp schema:about ?work ; schema:isPartOf <https://en.wikipedia.org/> }
    OPTIONAL{ ?work rdfs:label ?title filter(lang(?title) = "en") }
    }
    

Films edit

Films with "it" in the title edit

SELECT ?item ?title ?itemDescription
WHERE {
  ?item wdt:P31 wd:Q11424;
        wdt:P1476 ?title.
  BIND(LCASE(?title) AS ?normalised)
  FILTER (CONTAINS(?normalised, ' it ')|| STRSTARTS(?normalised, 'it ') || STRENDS(?normalised, ' it'))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY (?title)
Try it!

First lines edit

What kinds of things have first lines? edit

The following query uses these:

  • Properties: first line (P1922)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT (COUNT(?thing) AS ?count) ?typeLabel WHERE {
    ?thing wdt:P1922 [];
           wdt:P31 ?type.
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru"}
    } GROUP BY ?typeLabel
    ORDER BY DESC(?count)
    

Poems, their languages, and the languages of their first lines edit

The following query uses these:

  • Properties: first line (P1922)  View with Reasonator View with SQID, ISO 639-1 code (P218)  View with Reasonator View with SQID, original language of film or TV show (P364)  View with Reasonator View with SQID
    SELECT (COUNT(?thing) AS ?count) ?langLabel ?langlineLabel WHERE {
    ?thing wdt:P1922 ?line.
    BIND(lang(?line) AS ?langlinecode)
    ?langline wdt:P218 ?langlinecode
    OPTIONAL { ?thing wdt:P364 ?lang }
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru"}
    } GROUP BY ?langLabel ?langlineLabel
    ORDER BY ?langLabel DESC(?count)
    

Works where the language of the first line differs from the original language of the work edit

The following query uses these:

  • Properties: first line (P1922)  View with Reasonator View with SQID, language of work or name (P407)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID, ISO 639-1 code (P218)  View with Reasonator View with SQID
    SELECT ?work ?workLabel ?authorLabel ?langLabel ?langlineLabel WHERE {
    ?work wdt:P1922 ?line;
           wdt:P407 ?lang
    OPTIONAL {?work wdt:P50 ?author}
    BIND(lang(?line) AS ?langlinecode)
    ?langline wdt:P218 ?langlinecode
    FILTER (?langline != ?lang)
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru"}
    } ORDER BY ?langLabel
    

Wikisource maintenance edit

English Wikisource texts with a Wikidata entry but no indication of what they are edit

Priority given to those that have more statements in Wikidata

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID
    SELECT ?ws ?wsLabel ?wsDescription ?statementcount
    WHERE {
    ?article schema:about ?ws;
        schema:isPartOf <https://en.wikisource.org/>.
    ?ws wikibase:statements ?statementcount
    MINUS {?ws wdt:P31 [] } # No "instance of" property
    MINUS {?ws wdt:P279 [] } # No "subclass of" property
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY DESC(?statementcount)
    LIMIT 200
    

English Wikisource texts with an "instance of": count by type edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID
    SELECT ?type ?typeLabel (COUNT(?ws) as ?count) (COUNT(?date) as ?have_date)
    WHERE {
    ?article schema:about ?ws;
    	schema:isPartOf <https://en.wikisource.org/>.
    ?ws wdt:P31 ?type
    OPTIONAL {?ws wdt:P577 ?date}
    MINUS {?type wdt:P279+ wd:Q17442446}
    MINUS {?type wdt:P279 wd:Q14204246}
    MINUS {?type wdt:P279+ wd:Q17379835}
    OPTIONAL {?type rdfs:label ?typeLabel filter(lang(?typeLabel) = "en") }
    } GROUP BY ?type ?typeLabel
    ORDER BY DESC(?count)
    

Dead people with a Project Gutenberg ID but no English Wikisource profile, whose main language is English edit

SELECT DISTINCT ?person ?personLabel ?personDescription ?language ?death (URI(CONCAT("https://www.gutenberg.org/ebooks/author/", ?gutenberg)) AS ?gberglink) WHERE {
  ?person wdt:P1938 ?gutenberg;
    wdt:P570 ?death. # Dead people only
  FILTER (?death <= "1946-01-01T00:00:00Z"^^xsd:dateTime)
  MINUS {
    ?enws schema:about ?person;
      schema:isPartOf <https://en.wikisource.org/>
  }
  OPTIONAL {?person wdt:P1412 ?lang}.
  FILTER (!BOUND(?lang) || ?lang = wd:Q1860) # Language: English or absent
  BIND(IF(BOUND(?lang),"English","Not specified") AS ?language
)
  SERVICE wikibase:label {
       bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"
    }
}
ORDER BY ?death
Try it!

Project Gutenberg edit

Authors by gender edit

#title:Gutenberg authors by gender
#defaultView:BarChart
SELECT DISTINCT ?gender ?genderLabel (COUNT(?author) as ?count)
WHERE {
  ?author wdt:P1938 ?id ; wdt:P21 ?gender FILTER( !wikibase:isSomeValue(?gender) ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?gender ?genderLabel
Gutenberg authors by gender

Authors by nationality edit

#title:Gutenberg authors by nationality
#defaultView:BarChart
SELECT DISTINCT ?nat ?natLabel (COUNT(?author) as ?count)
WHERE {
  ?author wdt:P1938 ?id ; wdt:P27 ?nat FILTER( !wikibase:isSomeValue(?nat) ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?nat ?natLabel HAVING (?count > 50)
ORDER BY DESC(?count)
Gutenberg authors by nationality

Letters edit

See also Q1784733 Correspondence

Authors of notable letters, by number of letters edit

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT ?author ?authorLabel ?authorDescription (COUNT(?letter) as ?count)
    WHERE {
      ?letter wdt:P50 ?author;
       wdt:P31 wd:Q133492.
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } GROUP BY ?author ?authorLabel ?authorDescription
    ORDER BY DESC(?count)
    

Recipients of notable letters, by number of letters edit

The following query uses these:

  • Properties: addressee (P1817)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT ?recipient ?recipientLabel ?recipientDescription (COUNT(?letter) as ?count)
    WHERE {
      ?letter wdt:P1817 ?recipient;
       wdt:P31 wd:Q133492.
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } GROUP BY ?recipient ?recipientLabel ?recipientDescription
    ORDER BY DESC(?count)
    

For the Wikisource text of letters, see s:Category:Letters

Lifeboat stations edit

Map of lifeboat stations, with ownership edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map{"hide":["?location"], "markercluster": { } }
SELECT ?url ?ownerLabel ?station ?stationLabel ?location (SAMPLE(?image) AS ?image)
WHERE {
?station wdt:P31 wd:Q11997323;
  wdt:P625 ?location.
OPTIONAL { ?station wdt:P18 ?image}
OPTIONAL { ?station wdt:P127 ?owner}
OPTIONAL { ?station wdt:P856 ?url }
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,no,sv,da,de"}
} GROUP BY ?station ?stationLabel ?location ?ownerLabel ?url

Lifeboat stations lacking a location edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID
    SELECT ?station ?stationLabel ?countryLabel
    WHERE {
    ?station wdt:P31 wd:Q11997323;
     wdt:P17 ?country.
    MINUS {?station wdt:P625 ?location}
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,no,sv,da,de"}
    } ORDER BY ?countryLabel
    

World War I edit

Notable people from a specific region who fought in World War I edit

Without images edit

The following query uses these:

  • Properties: place of birth (P19)  View with Reasonator View with SQID, located in the administrative territorial entity (P131)  View with Reasonator View with SQID, shares border with (P47)  View with Reasonator View with SQID, conflict (P607)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID, image (P18)  View with Reasonator View with SQID, date of birth (P569)  View with Reasonator View with SQID, date of death (P570)  View with Reasonator View with SQID
    SELECT ?name (CONCAT("Born ",str(?born), ", ",?birthplace,"; Died ", str(?died)) as ?dates) ?article WHERE {
       ?person wdt:P19 ?place . # place of birth
       {?place wdt:P131* wd:Q23165 } UNION { ?place wdt:P131* ?county. ?county wdt:P47 wd:Q23165 }. # born in Oxfordshire or adjacent county 
       ?person wdt:P607 wd:Q361 . # involved in World War I
        # ?place wdt:P625 ?coord . # lat and long of birthplace
         MINUS { ?person wdt:P18 ?image }. #image
          ?person wdt:P569 ?dob . #date of birth
    	BIND(YEAR(?dob) as ?born).
        OPTIONAL { ?person wdt:P570 ?dod }. #date of death
      BIND(YEAR(?dod) as ?died).
       ?person rdfs:label ?name filter (lang(?name) = "en")
       ?place rdfs:label ?birthplace filter (lang(?birthplace) = "en")
    OPTIONAL{ ?article schema:about ?person. ?article schema:isPartOf <https://en.wikipedia.org/>.  }
    } ORDER by ?birthplace
    

With images edit

The following query uses these:

Features: ImageGrid (Q24515278)  View with Reasonator View with SQID

#defaultView:ImageGrid
SELECT DISTINCT ?image ?name (CONCAT("Born ",str(?born), "; Died ", str(?died)) as ?dates) ?birthplace ?article WHERE {
?person wdt:P19 ?place ; # place of birth
     wdt:P607 wd:Q361 ; # involved in World War I
     wdt:P18 ?image ; #image
     wdt:P569 ?dob #date of birth
{?place wdt:P131* wd:Q48015 } UNION { ?place wdt:P131* ?county. ?county wdt:P47 wd:Q23169 } # born in SE England or adjacent county to Oxfordshire 
OPTIONAL { ?person wdt:P570 ?dod } #date of death
BIND(YEAR(?dob) as ?born)
BIND(YEAR(?dod) as ?died)
?person rdfs:label ?name filter (lang(?name) = "en")
?place rdfs:label ?birthplace filter (lang(?birthplace) = "en")
OPTIONAL{ ?article schema:about ?person; schema:isPartOf <https://en.wikipedia.org/> }
}

Theses edit

All doctoral theses edit

Showing all theses whether or not they have author details, with optional author or author name string, year and institution.

The following query uses these:

Authors and their theses edit

Use this as a maintenance query to find thesis relationships that do not point to a publication (such as doctoral thesis, edition, thesis, or book)

The following query uses these:

Doctoral theses without an author edit

SELECT ?thesis ?thesisDescription ?languageLabel WHERE {
?thesis wdt:P31 wd:Q187685
MINUS { [] wdt:P1026 ?thesis }
MINUS { ?thesis wdt:P50 [] }
OPTIONAL { ?thesis wdt:P364 ?language }
SERVICE wikibase:label {
     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"
   }
}
Try it!

Doctoral thesis with an author, but the author has no thesis edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID, academic thesis (P1026)  View with Reasonator View with SQID
    SELECT ?thesis ?thesisDescription ?author ?authorLabel WHERE {
    ?thesis wdt:P31 wd:Q187685;
            wdt:P50 ?author.
    MINUS { ?author wdt:P1026 [] }
    SERVICE wikibase:label {
         bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"
       }
    }
    

Theses imported from Oxford Research Archive edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, dissertation submitted to (P4101)  View with Reasonator View with SQID, full work available at URL (P953)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID
    SELECT ?thesis ?thesisDescription ?authorLabel ?authorwp ?ora_url WHERE {
    ?thesis wdt:P31 wd:Q187685;  # doctoral theses
            wdt:P4101 wd:Q34433;  # submitted to University of Oxford
            wdt:P953 ?ora_url     # with open access link
    OPTIONAL {?thesis wdt:P50 ?author
    OPTIONAL{ ?authorwp schema:about ?author. ?authorwp schema:isPartOf <https://en.wikipedia.org/> } }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY DESC(?authorwp)
    

All properties of theses (query by User:Jheald) edit

The following query uses these:

  • Properties: subclass of (P279)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID
    SELECT ?prop ?propLabel ?count ?exampleLabel WHERE {
        {
            SELECT ?prop (COUNT(DISTINCT ?item) AS ?count) (SAMPLE(?id) AS ?example) WHERE {
               hint:Query hint:optimizer "None" .
               ?classes wdt:P279* wd:Q1266946 .
               ?item wdt:P31 ?classes .
               ?item ?p ?id .
               ?prop wikibase:directClaim ?p
            }  GROUP BY ?prop
        }
        SERVICE wikibase:label {
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"
        }
    } ORDER BY DESC (?count)
    

Oxford doctoral theses by their main topic edit

SELECT ?subject ?url ?qLabel ?attrib (YEAR(?inception) AS ?year) WHERE {
?q wdt:P4101 wd:Q34433; wdt:P921 ?subject; wdt:P953 ?url.
OPTIONAL {?q wdt:P50 ?author. ?author rdfs:label ?authorname FILTER(lang(?authorname)= "en") }
OPTIONAL {?q wdt:P2093 ?authorstring}
OPTIONAL {?q wdt:P571 ?inception}
BIND(IF(BOUND(?authorname),?authorname, ?authorstring) AS ?attrib).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

Sicily edit

Archaeological sites with lat-long pairs placing them in Sicily edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT ?place ?placeLabel ?latlong (SAMPLE(?image) as ?image)
WHERE
{ ?place wdt:P31/wdt:P279* wd:Q839954; # Archaeological site (or type of)
 wdt:P625 ?latlong;
 p:P625 ?statement . # coordinate-location statement
 OPTIONAL {?place wdt:P18 ?image }.
  ?statement psv:P625 ?coord.
  ?coord wikibase:geoLatitude ?lat .
  ?coord wikibase:geoLongitude ?long .
   FILTER (ABS(?lat - 37.5) < 1.3).
   FILTER (ABS(?long - 14) < 1.5).
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it" }
} GROUP BY ?place ?placeLabel ?latlong

Linguistics edit

Things called "___ phonology" edit

SELECT DISTINCT ?thing ?name WHERE {
VALUES ?prop {wdt:P279 wdt:P31}
?thing ?prop wd:Q40998; 
  rdfs:label ?name FILTER (lang(?name)="en") FILTER STRENDS(?name, " phonology")
} ORDER BY ?name
Try it!

Greek personal names edit

People of Ancient Greece edit

The following query uses these:

  • Properties: culture (P2596)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, country of citizenship (P27)  View with Reasonator View with SQID, residence (P551)  View with Reasonator View with SQID
    SELECT DISTINCT ?person ?en_name WHERE {
    {?person wdt:P2596 wd:Q11772. ?person wdt:P31 wd:Q5 } # Person & Culture: Ancient Greece
      UNION {?person wdt:P27/wdt:P31 wd:Q148837} # Citizen of a Polis
      UNION {?person wdt:P551/wdt:P31 wd:Q148837 } # Resident of a Polis
    OPTIONAL{ ?person rdfs:label ?en_name FILTER(lang(?en_name) = "en")}
    } ORDER BY ?en_name
    

846 results as of 9 Feb 2017

Personal names in Ancient Greek of individual Ancient Greek people edit

The following query uses these:

Cuneiform inscriptions edit

Items with a CDLI ID and their English Wikipedia articles edit

The following query uses these:

  • Properties: CDLI ID (P2474)  View with Reasonator View with SQID
    SELECT ?item ?itemLabel (URI(CONCAT("http://cdli.ucla.edu/search/archival_view.php?ObjectID=",?id)) AS ?cdli)  ?enwp WHERE {
      ?item wdt:P2474 ?id
    OPTIONAL{ ?enwp schema:about ?item; schema:isPartOf <https://en.wikipedia.org/> }
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
    }
    

Items plus Reasonator links edit

The following query uses these:

  • Properties: CDLI ID (P2474)  View with Reasonator View with SQID
    SELECT ?itemLabel (URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", SUBSTR(STR(?item),32) )) as ?reasonator) WHERE {
      ?item wdt:P2474 []
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
    }
    

Labels for CDLI items in all languages edit

The following query uses these:

  • Properties: CDLI ID (P2474)  View with Reasonator View with SQID
    SELECT ?id (lang(?label) AS ?lang) ?label WHERE {
      ?item wdt:P2474 ?id;
    rdfs:label ?label.
    } ORDER BY ?id ?lang
    

Commons categories with images of items edit

The following query uses these:

  • Properties: CDLI ID (P2474)  View with Reasonator View with SQID, Commons category (P373)  View with Reasonator View with SQID
    SELECT ?item ?itemLabel ?id (URI(CONCAT("https://commons.wikimedia.org/wiki/Category:",?commons)) AS ?images) WHERE {
      ?item wdt:P2474 ?id
    OPTIONAL{ ?item wdt:P373 ?commons }
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
    }
    

Ancient Greek pottery edit

All ancient Greek pottery items known to Wikidata, with Wikipedia links edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, from narrative universe (P1080)  View with Reasonator View with SQID
    SELECT DISTINCT ?item ?itemLabel ?itemDescription ?enwp WHERE {
    ?item wdt:P31/wdt:P279? wd:Q738680  # instance of type of ancient Greek pottery
    OPTIONAL {?enwp schema:about ?item; schema:isPartOf <https://en.wikipedia.org/> }
    MINUS {?item wdt:P1080 []} # exclude fictional (Pandora's Box)
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,el,fr,de,pl,uk"}
    }
    

Image gallery of ancient Greek pottery edit

The following query uses these:

Features: ImageGrid (Q24515278)  View with Reasonator View with SQID

#defaultView:ImageGrid
SELECT DISTINCT ?item ?itemLabel ?image WHERE {
?item wdt:P31/wdt:P279? wd:Q738680;  # instance of type of ancient Greek pottery
      wdt:P18 ?image 
MINUS {?item wdt:P1080 []} # exclude fictional (Pandora's Box)
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,el,fr,de,pl,uk"}
}

Visual graph of types of pottery edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT ?type ?typeLabel ?typeimage ?supertype ?supertypeLabel WHERE {
  ?type wdt:P279+ wd:Q17379525;
        wdt:P279 ?supertype
OPTIONAL{ ?type wdt:P18 ?typeimage }
SERVICE wikibase:label {
     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"
   }
  }

Shakespeare edit

Things named after Shakespeare's characters edit

The following query uses these:

  • Properties: named after (P138)  View with Reasonator View with SQID, present in work (P1441)  View with Reasonator View with SQID, author (P50)  View with Reasonator View with SQID
    SELECT DISTINCT ?obj ?objLabel ?objDescription ?char ?charLabel ?charDescription 
    WHERE {
    ?obj wdt:P138 ?char.
    ?char wdt:P1441/wdt:P50 wd:Q692 # Present in a work written by William Shakespeare
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER By ASC(?work)
    

Translation edit

Countries that have a Featured Article on Russian Wikipedia edit

SELECT ?sitelink ?itemLabel WHERE {
  ?item wdt:P31 wd:Q6256.
  ?sitelink schema:isPartOf <https://ru.wikipedia.org/>;
     schema:about ?item;
     wikibase:badge wd:Q17437796 .
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

People that have a Good Article in Spanish Wikipedia but a sub-good article in English Wikipedia edit

#title:People with a Good Article in Spanish Wikipedia but worse article in English Wikipedia
SELECT ?item ?itemLabel ?itemDescription ?enwp ?eswp WHERE {
  ?item wdt:P31 wd:Q5 .   # Human beings
  ?eswp schema:isPartOf <https://es.wikipedia.org/>; # Spanish article exists
     schema:about ?item;
     wikibase:badge wd:Q17437798 . # Spanish article has Good Article badge 
  ?enwp schema:isPartOf <https://en.wikipedia.org/>; # English article exists
     schema:about ?item.
  MINUS {?enwp wikibase:badge []} # English article lacks any kind of badge
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,es" }
} ORDER BY ?itemLabel
People with a Good Article in Spanish Wikipedia but worse article in English Wikipedia

German women with an article in English Wikipedia but not in German Wikipedia edit

SELECT ?item ?itemLabel ?itemDescription ?birthdate ?deathdate
WHERE
{ ?item wdt:P31 wd:Q5 ;
   wdt:P27 wd:Q183 ;
   wdt:P21 wd:Q6581072 ;
   wdt:P569 ?birthdate .
OPTIONAL { ?item wdt:P570 ?deathdate }
FILTER EXISTS { ?wen schema:about ?item ; schema:inLanguage "en" }
FILTER NOT EXISTS { ?wde schema:about ?item ; schema:inLanguage "de" }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de,en" }
} ORDER BY ?birthdate
Try it!

Works of Hans Sachs with links to their online text edit

The following query uses these:

  • Properties: author (P50)  View with Reasonator View with SQID, publication date (P577)  View with Reasonator View with SQID, full work available at URL (P953)  View with Reasonator View with SQID
    SELECT ?work ?workLabel ?year ?text ?wikisource
    WHERE {
    ?work wdt:P50 wd:Q19543; # author: Hans Sachs
       wdt:P577 ?pubdate.
    BIND(YEAR(?pubdate) AS ?year)
    OPTIONAL{?wikisource schema:about ?work; schema:isPartOf <https://de.wikisource.org/>} # text of work in German Wikisource
    OPTIONAL{?work wdt:P953 ?text} # link for text of work
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de,en"}
    } ORDER BY ?year
    

South African women on Wikipedia but not on Wikiquote edit

SELECT ?item ?itemLabel ?english ?afrik (SAMPLE(?workLabel) AS ?occupation) WHERE {
  ?item wdt:P27 wd:Q258; wdt:P21 wd:Q6581072
     MINUS{ ?englishq schema:about ?item ; schema:isPartOf <https://en.wikiquote.org/> }
     MINUS{ ?afrikq schema:about ?item ; schema:isPartOf <https://af.wikiquote.org/> }
     OPTIONAL{ ?english schema:about ?item ; schema:isPartOf <https://en.wikipedia.org/> }
     OPTIONAL{ ?afrik schema:about ?item ; schema:isPartOf <https://af.wikipedia.org/> }
  OPTIONAL{?item wdt:P106 ?work}
  FILTER (BOUND(?english)|| BOUND(?afrik))
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?item rdfs:label ?itemLabel. ?work rdfs:label ?workLabel}
} GROUP BY ?item ?itemLabel ?english ?afrik
Try it!

Politicians edit

What parliaments does Wikidata know about, and how many parliamentarians from each? edit

The following query uses these:

  • Properties: subclass of (P279)  View with Reasonator View with SQID, part of (P361)  View with Reasonator View with SQID, position held (P39)  View with Reasonator View with SQID, date of death (P570)  View with Reasonator View with SQID
    SELECT ?parliament ?parliamentLabel ?houseLabel (COUNT(?sen) AS ?members) (COUNT(?death) AS ?dead)
    WHERE { 
    ?parliament wdt:P279 wd:Q486839.
    OPTIONAL {?parliament wdt:P361 ?house }
    ?sen wdt:P39 ?parliament.
    OPTIONAL {?sen wdt:P570 ?death}
    FILTER (?parliament NOT IN (wd:Q928764, wd:Q1055894, wd:Q928764) )
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    GROUP BY ?parliament ?parliamentLabel ?houseLabel
    ORDER BY DESC(?members)
    

Places of education of Members of Parliament of the United Kingdom edit

The following query uses these:

Features: BubbleChart (Q24515280)  View with Reasonator View with SQID

#defaultView:BubbleChart
SELECT (COUNT(?mp) AS ?mps) ?education ?educationLabel ?educationDescription
WHERE { 
?mp wdt:P39 wd:Q16707842;
    wdt:P69 ?education.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?education ?educationLabel ?educationDescription
ORDER BY DESC(?mps)

Map of House of Commons constituencies edit

Wikipedia: w:en:List_of_United_Kingdom_Parliament_constituencies

OS Open data viewer for locating constituencies

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID, dissolved, abolished or demolished date (P576)  View with Reasonator View with SQID
    SELECT ?con ?conLabel ?loc ?enwp
    WHERE { ?con wdt:P31 wd:Q27971968;
       wdt:P625 ?loc.
     FILTER NOT EXISTS {?con wdt:P576 ?end} # Not abolished
     OPTIONAL{ ?enwp schema:about ?con. ?enwp schema:isPartOf <https://en.wikipedia.org/>}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
    } ORDER BY ?conLabel
    

Places of education of US senators edit

The following query uses these:

Features: BubbleChart (Q24515280)  View with Reasonator View with SQID

#defaultView:BubbleChart
SELECT (COUNT(?mp) AS ?mps) ?education ?educationLabel ?educationDescription
WHERE { 
?mp wdt:P39 wd:Q4416090;
    wdt:P69 ?education.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?education ?educationLabel ?educationDescription
ORDER BY DESC(?mps)

Places of education of US Representatives edit

The following query uses these:

  • Properties: position held (P39)  View with Reasonator View with SQID, educated at (P69)  View with Reasonator View with SQID
    SELECT (COUNT(?mp) AS ?mps) ?education ?educationLabel ?educationDescription
    WHERE { 
    ?mp wdt:P39 wd:Q13218630;
        wdt:P69 ?education.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } GROUP BY ?education ?educationLabel ?educationDescription
    ORDER BY DESC(?mps)
    

Jobs British MPs have had, other than politician or MP edit

The following query uses these:

Features: BubbleChart (Q24515280)  View with Reasonator View with SQID

#defaultView:BubbleChart
SELECT (COUNT(DISTINCT ?mp) as ?mps) ?job ?jobLabel
WHERE { 
?mp wdt:P31 wd:Q5; wdt:P39/wdt:P279? wd:Q16707842;
    wdt:P106 ?job.
FILTER (?job not in (wd:Q82955, wd:Q486839) )
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?job ?jobLabel
ORDER BY DESC(?mps)

Updated July 2021.

Jobs held by senators in the US, other than Senator or politician edit

The following query uses these:

Features: BubbleChart (Q24515280)  View with Reasonator View with SQID

#defaultView:BubbleChart
SELECT (COUNT(?sen) AS ?sens) ?job ?jobLabel
WHERE { 
?sen wdt:P39 wd:Q4416090;
    wdt:P106 ?job.
FILTER (?job not in (wd:Q82955, wd:Q4416090) )
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?job ?jobLabel
ORDER BY DESC(?sen)

Parliaments and most commonly occurring jobs for members of each edit

With thanks to User:Pasleim

Link for more about the named subquery pattern

The following query uses these:

  • Properties: position held (P39)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID
    select ?parliament ?parliamentLabel ?job ?jobLabel ?s
      WITH {
         SELECT (COUNT(?sen) AS ?sens) ?job ?parliament  WHERE { 
          ?sen wdt:P39 ?parliament;
              wdt:P106 ?job.
          ?parliament wdt:P279* wd:Q486839  
          FILTER (?job != wd:Q82955)
        } GROUP BY ?job ?parliament HAVING (?sens > 1)
      } AS %subquery                  
    WHERE{
      {
        SELECT ?parliament (MAX(?sens) AS ?s) WHERE{
          INCLUDE %subquery
        } GROUP BY ?parliament
      } 
      INCLUDE %subquery
      FILTER(?s = ?sens)
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }  
    } ORDER BY DESC(?s)
    

Members of the Whig party edit

The following query uses these:

  • Properties: member of political party (P102)  View with Reasonator View with SQID, place of birth (P19)  View with Reasonator View with SQID, place of death (P20)  View with Reasonator View with SQID
    SELECT ?person ?personLabel ?birthLabel ?deathLabel
    WHERE {
    ?person wdt:P102 wd:Q108700
    OPTIONAL{ ?person wdt:P19 ?birth }
    OPTIONAL{ ?person wdt:P20 ?death }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER by ?personLabel
    

Mapping the UK edit

Table of "shares border with" relations of English, Welsh and Scottish counties edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, shares border with (P47)  View with Reasonator View with SQID, reference URL (P854)  View with Reasonator View with SQID
    SELECT ?place1 ?place1Label ?place2 ?place2Label ?refurl WHERE {
    ?place1 p:P47 ?statement;
      wdt:P31 ?place1type.
    ?statement ps:P47 ?place2;
    FILTER (?place1type IN (wd:Q180673, wd:Q1138494, wd:Q15979307, wd:Q202435, wd:Q15060255)).
    OPTIONAL {?statement prov:wasDerivedFrom/pr:P854 ?refurl}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Map of National Trust properties edit

#defaultView:Map{"hide": ["?coord"]}
#title:Map of National Trust properties
SELECT ?park ?parkLabel ?coord ?image ?web WHERE {
?park wdt:P127 wd:Q333515;
   wdt:P625 ?coord.
OPTIONAL { ?park wdt:P18 ?image }
OPTIONAL { ?park wdt:P856 ?web }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Map of National Trust properties

National Trust properties for which Wikidata lacks the official web link edit

SELECT ?park ?parkLabel ?parkDescription (SAMPLE(?image) AS ?image) WHERE {
?park wdt:P127 wd:Q333515.
 MINUS {?park wdt:P31/wdt:P279* wd:Q4502142} # Remove artworks
OPTIONAL { ?park wdt:P18 ?image }
MINUS { ?park wdt:P856 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?park ?parkLabel  ?parkDescription
ORDER BY ?parkLabel
Try it!

List of properties marked as owned by National Trust edit

The following query uses these:

  • Properties: owned by (P127)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID, image (P18)  View with Reasonator View with SQID, official website (P856)  View with Reasonator View with SQID
    SELECT ?park ?parkLabel (SAMPLE(?coord) AS ?coord) (SAMPLE(?image) AS ?image) ?web WHERE {
    ?park wdt:P127 wd:Q333515.
     MINUS {?park wdt:P31/wdt:P279* wd:Q4502142} # Remove artworks
    OPTIONAL { ?park wdt:P625 ?coord }
    OPTIONAL { ?park wdt:P18 ?image }
    OPTIONAL { ?park wdt:P856 ?web }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } GROUP BY ?park ?parkLabel ?web
    ORDER BY ?parkLabel
    

"Shares border with" relations of UK parliamentary constituencies edit

Data presently very sparse indeed!

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, shares border with (P47)  View with Reasonator View with SQID, reference URL (P854)  View with Reasonator View with SQID
    SELECT ?place1 ?place1Label ?place2 ?place2Label ?refurl WHERE {
    ?place1 p:P47 ?statement;
      wdt:P31 ?place1type.
    ?statement ps:P47 ?place2;
    FILTER (?place1type IN (wd:Q27971968)).
    OPTIONAL {?statement prov:wasDerivedFrom/pr:P854 ?refurl}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Mapping globally edit

Wikidata Graph Builder edit

Very silly map of the contiguous US, as a query edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT ?place1 ?place1Label ?place2 ?place2Label WHERE {
?place1 wdt:P31 wd:Q35657;
  wdt:P47 ?place2.
?place2 wdt:P31 wd:Q35657.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

What kinds of thing have geoshapes? edit

#title:Types of thing that have a Geoshape on Commons
SELECT (COUNT(?item) AS ?count) ?type ?typeLabel WHERE {
  ?item wdt:P3896 []; wdt:P31 ?type
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?type ?typeLabel
ORDER BY DESC(?count)
Types of thing that have a Geoshape on Commons

Countries, their first-level administrative subdivisions, the total number of subdivisions, and the number with borders to other subdivisions edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, shares border with (P47)  View with Reasonator View with SQID
    SELECT ?countryLabel ?divisiontype ?divisiontypeLabel (COUNT(?division) AS ?total) (COUNT(?bordered) AS ?with_borders) WHERE {
    ?division wdt:P31 ?divisiontype.
    ?divisiontype wdt:P279 wd:Q10864048;
      wdt:P17 ?country.
    OPTIONAL {?division wdt:P47 ?bordered. ?bordered wdt:P31 ?divisiontype}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } GROUP BY ?countryLabel ?divisiontype ?divisiontypeLabel
    ORDER BY ?countryLabel
    

Map of US National Parks, including official web sites and Twitter accounts edit

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT ?park ?parkLabel ?coord ?image ?web (URI(CONCAT("https://twitter.com/",?tw)) AS ?twitter) WHERE {
?park wdt:P31 wd:Q5408678; wdt:P625 ?coord; wdt:P18 ?image; wdt:P856 ?web
  OPTIONAL {?park wdt:P2002 ?tw}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?parkLabel

Global map of national parks edit

#defaultView:Map{"hide": ["?coord"], "markercluster": { } }
#title:Global map of national parks
SELECT ?park ?countryLabel ?parkLabel ?coord (SAMPLE(?image) AS ?image) ?web WHERE {
?park wdt:P31/wdt:P279* wd:Q46169; wdt:P625 ?coord.
  OPTIONAL {?park wdt:P18 ?image}
  OPTIONAL {?park wdt:P856 ?web}
  OPTIONAL {?park wdt:P17 ?country}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?park ?countryLabel ?parkLabel ?coord ?web
Global map of national parks

Checking which nuclear power stations have Inception and which have Service entry edit

SELECT ?object ?objectLabel ?countryLabel ?inception ?service_entry WHERE { 
?object (wdt:P31/wdt:P279*) wd:Q134447;
   wdt:P17 ?country.
  OPTIONAL {?object wdt:P571 ?inception}
  OPTIONAL {?object wdt:P729 ?service_entry }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
  } ORDER BY ?countryLabel
Try it!

Sister-city relations between cities that have millions of inhabitants edit

#defaultView:Graph
SELECT ?city ?cityLabel ?image ?cityB
WHERE {
  ?cityB wdt:P31 wd:Q1637706 .
  ?city wdt:P31 wd:Q1637706 ;
        wdt:P190 ?cityB ;
        wdt:P18 ?image
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Things that are "located in" cities, but very far from those cities edit

SELECT DISTINCT ?thing ?thingLabel ?city ?cityLabel ?distnum WHERE {
?thing wdt:P131 ?city; wdt:P625 ?thingloc.
?city wdt:P31 wd:Q515; wdt:P625 ?cityloc.
  BIND(geof:distance(?thingloc, ?cityloc) AS ?distnum)
FILTER (?distnum > 60)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?distnum)
Try it!

Social media edit

What kinds of notable things have Twitter accounts? edit

As of 2022, this seems to time out and I can't get it to work within one minute. :(

SELECT ?type ?typeLabel (COUNT(?thing) AS ?things) WHERE {
?thing wdt:P2002 ?tw;
       wdt:P31 ?type.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?type ?typeLabel
ORDER BY DESC(?things)
Try it!

What kinds of notable things have Instagram accounts? edit

As of 2022, this seems to time out and I can't get it to work within one minute.

SELECT ?type ?typeLabel (COUNT(?thing) AS ?things) WHERE {
?thing wdt:P2003 [];
       wdt:P31 ?type.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?type ?typeLabel
ORDER BY DESC(?things)
Try it!

Number of Facebook IDs versus number of Twitter IDs for things that are not people edit

SELECT ?type ?typeLabel ((COUNT(?tw)) AS ?twitter) (COUNT(?fb) AS ?facebook) WHERE {
{?t wdt:P2002 ?tw} UNION {?t wdt:P2013 ?fb}
      ?t wdt:P31 ?type.
  FILTER (?type != wd:Q5)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?type ?typeLabel
ORDER BY DESC(?twitter)
LIMIT 80
Try it!

Mastodon accounts edit

#title:Mastodon accounts and corresponding Twitter accounts
SELECT ?twit ?item ?itemLabel ?itemDescription ?id WHERE {
  ?item wdt:P4033 ?id.
  OPTIONAL {?item wdt:P2002 ?twit}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?itemLabel
Mastodon accounts and corresponding Twitter accounts

Fictional worlds edit

Overview of types of fictional characters in Wikidata edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID
    SELECT ?type ?typeLabel (COUNT(?character) AS ?count)
    WHERE {
    ?character wdt:P31 ?type.
    ?type wdt:P279* wd:Q95074
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } GROUP BY ?type ?typeLabel ORDER BY DESC(?count)
    

Group membership of wizards in the Harry Potter universe edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT ?wizard ?wizardLabel ?groupLabel ?group WHERE {
?wizard wdt:P31 wd:Q15298259; # in Harry Potter universe  
  wdt:P463 ?group
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

TreeView Map of houses and groups in the HP universe edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, member of (P463)  View with Reasonator View with SQID
    #defaultView:TreeMap
    SELECT ?group ?groupLabel ?wizardLabel ?wizard WHERE {
    ?wizard wdt:P31 wd:Q15298259; # in Harry Potter universe  
      wdt:P463 ?group.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    }
    

Created for the blog post "Wizards, Muggles and Wikidata: The Room of Requirements for structured knowledge"

Characters and real people that inspired them edit

P794 ("as") needs to be replaced by P3831 ("object has role")

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, inspired by (P941)  View with Reasonator View with SQID, P794
    SELECT DISTINCT ?fiction ?fictionLabel ?fictionDescription ?realLabel ?realDescription ?asLabel WHERE {
    ?fiction p:P941 ?statement;
             wdt:P31/wdt:P279* wd:Q95074.
      ?statement ps:P941 ?real.
      ?real wdt:P31 wd:Q5
    OPTIONAL {?statement pq:P794 ?as}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?fictionLabel
    

Characters and what they are named after edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, named after (P138)  View with Reasonator View with SQID
    SELECT DISTINCT ?char ?charLabel ?charDescription ?after ?afterLabel ?afterDescription WHERE {
    ?char wdt:P31/wdt:P279? wd:Q95074 ;
     wdt:P138 ?after .
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?charLabel
    

Things that are "based on" a person edit

English description of based on (P144) suggests the object has to be a work.

SELECT DISTINCT ?thing ?thingLabel ?thingDescription ?personLabel WHERE {
?thing wdt:P144 ?person.
  ?person wdt:P31 wd:Q5 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

Fictional wars edit

Based on a query by User:Kaitary

#defaultView:Graph
SELECT ?from ?fromLabel ?to ?toLabel ?rgb WHERE {
  {SELECT (?fictional_war AS ?from) (?universe AS ?to) ("F7FF00" as ?rgb) WHERE {
  ?fictional_war wdt:P31 wd:Q17198419. OPTIONAL{?fictional_war wdt:P1080 ?narr_universe}
    OPTIONAL {?fictional_war wdt:P8345 ?franchise }
    OPTIONAL {?fictional_war wdt:P1441 ?work }
    BIND(COALESCE(?narr_universe, ?franchise, ?work, '') AS ?universe)
  } }
UNION {SELECT (?participant AS ?from) (?fictional_war AS ?to) ("7FFF00" as ?rgb) WHERE {
   ?fictional_war wdt:P31 wd:Q17198419.
OPTIONAL { ?fictional_war wdt:P710 ?participant } } }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

BBC Television series edit

SELECT DISTINCT ?serLabel
(URI(CONCAT("https://random.tv.longair.net/series/", SUBSTR(STR(?ser),32) )) as ?link)
WHERE {
?ser wdt:P31/wdt:P279? wd:Q5398426. # Television series, including miniseries etc.
{?ser wdt:P272 wd:Q9531} UNION {?ser wdt:P449/wdt:P137 wd:Q9531 } # Produced by BBC or originally on channel owned by BBC
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?serLabel
Try it!

Doctoral advisor family trees edit

Longest (years) chains of doctoral advisors edit

SELECT DISTINCT ?p1 ?p1Label ?p1birth ?p2 ?p2Label ?p2birth ?diff WHERE {
?p2 wdt:P184/wdt:P184/wdt:P184/wdt:P184/wdt:P184/wdt:P184/wdt:P184/wdt:P184/wdt:P184+ ?p1;
    wdt:P569 ?p2birth.
?p1 wdt:P569 ?p1birth.
  BIND(YEAR(?p2birth) - YEAR(?p1birth) AS ?diff)
  FILTER ( ?diff > 700)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY DESC(?diff)
Try it!

Chain between two people edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT DISTINCT ?person2 ?person2Label ?person1 ?person1Label?p2birth WHERE {
wd:Q22092846 wdt:P184* ?person2.
?person1 wdt:P184* wd:Q3118446.
?person2 wdt:P184 ?person1;
   wdt:P569 ?p2birth.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY DESC(?p2birth)

Scholarly societies edit

Graph of co-membership between scholarly societies edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT ?person ?personLabel ?group ?groupLabel ("7FFF00" as ?rgb)
WHERE {
  ?person wdt:P570 ?death FILTER (YEAR(?death) < 1800).
  ?person wdt:P463 wd:Q123885. # That ?person is a person is implicit through membership
  ?person wdt:P463 ?group FILTER (?group != wd:Q123885).
  ?group wdt:P31/wdt:P279? wd:Q955824.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

TODO: Filter out those who are just members of the RS and no other society

UK National Archives edit

Property: UK National Archives ID (P3029)

UKNA IDs of people who studied at Oxford and have an English Wikipedia page edit

SELECT ?personLabel ?enwp (URI(CONCAT("https://discovery.nationalarchives.gov.uk/details/c/",?ukna)) AS ?uknalink) WHERE {
?person wdt:P3029 ?ukna.
?person wdt:P69 wd:Q34433.
?enwp schema:about ?person; schema:isPartOf <https://en.wikipedia.org/>
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?personLabel
Try it!

UKNA links for UK cabinet ministers, with post held edit

SELECT ?person ?personLabel ?positionLabel ?date (URI(CONCAT("https://discovery.nationalarchives.gov.uk/details/c/",?ukna)) AS ?url) WHERE {
?person wdt:P3029 ?ukna; # person in UK National Archives
   wdt:P39 ?position . ?position wdt:P361 wd:Q112014. # held position in Cabinet of the UK
 ?person wdt:P570 ?date # death date
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Histropedia timeline of this query: https://tinyurl.com/yy7dxstn

People who have a UKNA ID and a US NARA ID edit

SELECT ?personLabel ?personDescription (URI(CONCAT("https://discovery.nationalarchives.gov.uk/details/c/",?ukna)) AS ?uknalink)
(URI(CONCAT("https://catalog.archives.gov/id/",?nara)) as ?naralink) WHERE {
?person wdt:P3029 ?ukna; wdt:P1225 ?nara.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?personLabel
Try it!

Archives at: archives at (P485)

Taxonomies edit

Species and their sitelinks edit

SELECT ?species ?speciesLabel ?sitelink
WHERE {
?species wdt:P171* wd:Q7377 # Sub-species of mammal
FILTER NOT EXISTS { [] wdt:P171 ?species } # Leaf nodes only
?sitelink schema:about ?species. # Page 'about' species: could be Wikipedia article or not
?species rdfs:label ?speciesLabel filter (lang(?speciesLabel) = "en")
}
Try it!

Taxa of equivalent rank to Mammal edit

SELECT ?taxon ?taxonLabel
WHERE {
?taxon wdt:P105 wd:Q37517 . # taxonomic rank: Class
?taxon rdfs:label ?taxonLabel filter (lang(?taxonLabel) = "en")
}
Try it!

Parent taxa of a particular species, with their rank edit

SELECT ?item ?itemLabel ?classLabel
WHERE
{
  wd:Q42196 wdt:P171* ?item .
  ?item wdt:P105 ?class
  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

'Leaf' taxa, their three super-taxa, and the rank of the highest super-taxon edit

The following query uses these:

  • Properties: parent taxon (P171)  View with Reasonator View with SQID, taxon rank (P105)  View with Reasonator View with SQID
    SELECT ?item ?itemLabel ?item2Label ?item3Label ?item4Label ?item4rankLabel
    WHERE {
    ?item wdt:P171+ wd:Q7377 .
    FILTER NOT EXISTS { [] wdt:P171 ?item } # Leaf nodes only
    ?item wdt:P171 ?item2 .
    ?item2 wdt:P171 ?item3 .
    ?item3 wdt:P171 ?item4 .
    ?item4 wdt:P105 ?item4rank
    SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    } ORDER BY ?item4Label ?item3Label
    

Taxons with an eBird identifier (i.e. birds), their Q number and number of Wikipedia articles edit

SELECT ?wd ?wdLabel ?ebird_id (COUNT(?sitelink) AS ?sites) WHERE {
?wd wdt:P3444 ?ebird_id.
OPTIONAL {?sitelink schema:about ?wd FILTER(CONTAINS(str(?link), ".wikipedia.org/"))}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?wd ?wdLabel ?ebird_id
Try it!

IUCN conservation statuses and number of taxa in Wikidata edit

#title:IUCN conservation statuses
SELECT ?status ?statusLabel (COUNT(?taxon) AS ?count) WHERE {
?taxon wdt:P141 ?status
       SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?status ?statusLabel
IUCN conservation statuses

For a given conservation status, taxa in Wikimedia but with no English Wikipedia article edit

#Endangered taxa with representation on Wikimedia but no English Wikipedia article
SELECT ?item ?itemLabel ?links (URI(CONCAT("https://www.iucnredlist.org/details/",?iucn_id,"/0")) AS ?iucn_link) WHERE {
  ?item wdt:P141 wd:Q11394 . # IUCN status: Endangered
  ?item wikibase:sitelinks ?links FILTER (?links > 1)  # More than 1 page on Wikimedia
  MINUS{?enwp schema:about ?item; schema:isPartOf <https://en.wikipedia.org/> } # Not in English Wikipedia
  OPTIONAL{?item wdt:P627 ?iucn_id} # Get IUCN link if available
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Names edit

Things called "cancer", ordered by number of sitelinks edit

SELECT ?itemLabel ?item ?itemDescription ?sites WHERE {
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "EntitySearch" .
      bd:serviceParam wikibase:endpoint "www.wikidata.org" .
      bd:serviceParam mwapi:search "cancer" .
      bd:serviceParam mwapi:language "en" .
      ?item wikibase:apiOutputItem mwapi:item
  }
  ?item wikibase:sitelinks ?sites.
MINUS {?item wdt:P31 wd:Q4167410} # Exclude Wikimedia disambiguation pages
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
} ORDER BY DESC(?sites)
Try it!

Places in France whose names end in "ange" edit

Created in response to a thread on Reddit.

SELECT ?city ?name WHERE {
?city wdt:P17 wd:Q142;
      wdt:P625 [].
?city rdfs:label ?name FILTER (lang(?name)="fr") FILTER ( REGEX(?name, "ange$", "") )
}
Try it!

Phrasebook for types of food edit

SELECT ?lang1 ?desc ?lang2 WHERE {
?item wdt:P279 wd:Q2095.
 ?item rdfs:label ?lang1 FILTER(lang(?lang1) = "en").
 ?item schema:description ?desc FILTER(lang(?desc) = "en").
 ?item rdfs:label ?lang2 FILTER(lang(?lang2) = "ca")
} ORDER BY ?lang1
Try it!

Things that are described by an English language resource but lack an English label edit

#title:Things that are described by an English language resource but lack an English label
SELECT ?item ?url ?sites WHERE {
  ?item p:P973 ?s. ?s ps:P973 ?url . ?s pq:P407 wd:Q1860 .
  ?item wikibase:sitelinks ?sites
  FILTER NOT EXISTS{?item rdfs:label ?label FILTER(LANG(?label) = "en") }
} ORDER BY DESC(?sites)
Things that are described by an English language resource but lack an English label

Religious houses edit

Monasteries in the United Kingdom edit

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, located in the administrative territorial entity (P131)  View with Reasonator View with SQID, religious order (P611)  View with Reasonator View with SQID, coordinate location (P625)  View with Reasonator View with SQID
    SELECT ?label ?subj (SAMPLE(?whereLabel) AS ?where) (SAMPLE(?countryLabel) as ?country) (SAMPLE(?orderLabel) AS ?order) WHERE
    {  ?subj wdt:P31/wdt:P279? ?type ;
          rdfs:label ?label filter (lang(?label) = "en")
    ?type wdt:P279? wd:Q44613. # instance of monastery or subtype
    OPTIONAL { ?subj wdt:P17/rdfs:label ?countryLabel filter (lang(?countryLabel) = "en") }
    OPTIONAL { ?subj wdt:P131/rdfs:label ?whereLabel filter (lang(?whereLabel) = "en") }
    OPTIONAL { ?subj wdt:P611/rdfs:label ?orderLabel filter (lang(?orderLabel) = "en") }
    MINUS {?subj wdt:P17 wd:Q142 } # not France
     MINUS {?subj wdt:P17 wd:Q27 } # not Ireland
    ?subj p:P625/psv:P625 ?loc. # coordinate-location statement
      ?loc wikibase:geoLatitude ?lat .
      ?loc wikibase:geoLongitude ?long .
       FILTER (?lat > 50) FILTER (?lat < 63)
       FILTER (?long > -10.5) FILTER (?long < 2.02) 
    } GROUP BY ?label ?subj
    ORDER BY ?label
    

Images edit

Some things with a Commons category but no specified image edit

SELECT ?thing ?thingLabel ?cat WHERE {
?thing wdt:P373 ?cat;
       wdt:P31/wdt:P279* wd:Q39546
MINUS { ?thing wdt:P18 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} LIMIT 50
Try it!

China Biographical Database edit

See also Wikidata:WikiProject_East_Asia/China_Biographical_Database_import

CBDB-VIAF mapping edit

The following query uses these:

  • Properties: CBDB ID (P497)  View with Reasonator View with SQID, VIAF ID (P214)  View with Reasonator View with SQID
    SELECT ?item ?en_name ?zh_name ?cbdb ?viaf WHERE {
    ?item wdt:P497 ?cbdb;
          wdt:P214 ?viaf.
    OPTIONAL{ ?item rdfs:label ?en_name filter (lang(?en_name) = "en") }
    OPTIONAL{ ?item rdfs:label ?zh_name filter (lang(?zh_name) = "zh") }
    } ORDER BY ?cbdb
    

All non-CBDB IDs for things with a CBDB ID edit

SELECT ?cbdb ?idlabel ?value WITH {
  SELECT DISTINCT ?item ?cbdb WHERE {
    ?item wdt:P497 ?cbdb
  }
} AS %subquery WHERE {
  INCLUDE %subquery .
  ?id wikibase:propertyType wikibase:ExternalId; wikibase:claim ?p; wikibase:statementProperty ?ps; wdt:P31/wdt:P279* wd:Q19595382 FILTER( ?id != wd:P497 ).
  ?item ?p [ ?ps ?value ] .
  ?id rdfs:label ?idlabel FILTER (lang(?idlabel) = "en").

} ORDER BY ?idlabel
Try it!

Things with a CBDB ID but no country (/ gender) edit

SELECT ?wd (CONCAT("http://db1.ihp.sinica.edu.tw/cbdbc/cbdbkmeng?~~AAA",?cbdb) AS ?cbdb_url) ?period WHERE {
?wd wdt:P497 ?cbdb.
OPTIONAL {?wd wdt:P2348 ?period}
MINUS {?wd wdt:P27 [] } # country
#MINUS {?wd wdt:P21 [] } # gender
}
Try it!

Historic China edit

moved to User:MartinPoulter/queries/collections#Historic_China

Geography of India edit

Districts and Regions of India (with Geonames) edit

SELECT ?place ?placeLabel ?region ?regionLabel ?geonamesID WHERE {
?place wdt:P31 wd:Q1149652;
       wdt:P17 wd:Q668.
OPTIONAL{ ?place wdt:P131 ?region 
            MINUS {?region wdt:P576 [] } # region not abolished
        }
OPTIONAL {?place wdt:P1566 ?geonamesID }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?regionLabel ?placelabel
Try it!

Temples and palaces in India edit

SELECT ?building ?buildingLabel ?place ?placeLabel WHERE {
VALUES ?type { wd:Q32815 wd:Q16560 } # palaces, temples . mosques= wd:Q44539 
  ?building wdt:P31/wdt:P279* ?type;
          wdt:P17 wd:Q668. # in India
OPTIONAL{ ?building wdt:P131 ?place }
OPTIONAL{ ?building wdt:P625 ?coords }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,id". }
} ORDER BY ?regionLabel ?placelabel
Try it!

Similarity edit

Similarities between Calvin and Hobbes edit

SELECT ?thing ?thingLabel WHERE {
{wd:Q37577 ?p1 ?thing} UNION {?thing ?p1 wd:Q37577} # calvin
{wd:Q37621 ?p2 ?thing} UNION {?thing ?p2 wd:Q37621} # hobbes
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Periodic table edit

Countries of citizenship of discoverers of elements edit

SELECT ?countryLabel (COUNT(?element) AS ?count) (GROUP_CONCAT(DISTINCT ?elementLabel) AS ?list) WHERE {
?element wdt:P31 wd:Q11344; # chemical element
         wdt:P61/wdt:P27 ?country. # nationality of discoverer
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                        ?country rdfs:label ?countryLabel. ?element rdfs:label ?elementLabel}
} GROUP BY ?countryLabel
ORDER BY DESC (?count)
Try it!

Elements, their discoverers and years of discovery edit

SELECT ?element ?elementLabel ?atomicno (GROUP_CONCAT(?discovererLabel; separator=", ") AS ?discoverers) (MIN(YEAR(?discovery)) AS ?year) WHERE {
?element wdt:P31 wd:Q11344; # chemical element
         wdt:P1086 ?atomicno
OPTIONAL{?element wdt:P61 ?discoverer}
OPTIONAL{?element wdt:P575 ?discovery}
MINUS{?element wdt:P279|wdt:P31 wd:Q1299291} # Remove hypothetical elements
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                          ?element rdfs:label ?elementLabel. ?discoverer rdfs:label ?discovererLabel }
} GROUP BY ?element ?elementLabel ?atomicno
ORDER BY ?atomicno
Try it!

Databases and digital libraries edit

Sources of data for research edit

Based on a query by @WikiDigi on Twitter

SELECT DISTINCT ?storeLabel ?url (GROUP_CONCAT(DISTINCT ?typeLabel;separator=", ") AS ?types) ?subjectLabel
WHERE {
VALUES ?type {wd:Q5227308 wd:Q22692845 wd:Q7689673 wd:Q4117139
                          wd:Q5281480 wd:Q212805 wd:Q5570651}
?store wdt:P31/wdt:P279* ?type; 
         wdt:P856 ?url;
         wdt:P31 ?type
MINUS {?store wdt:P576 []}
OPTIONAL {?store wdt:P921 ?subject.}
SERVICE wikibase:label {
  bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
  ?type rdfs:label ?typeLabel. ?store rdfs:label ?storeLabel. ?subject rdfs:label ?subjectLabel
                       }
} GROUP BY ?storeLabel ?url ?subjectLabel ORDER BY UCASE(?storeLabel)
Try it!

Sources of data lacking the Official URL property edit

SELECT ?store ?storeLabel ?typeLabel WHERE {
VALUES ?type { wd:Q22692845 wd:Q7689673 wd:Q4117139 wd:Q5227308 wd:Q5570651 wd:Q5281480 wd:Q212805 }
?store wdt:P31 ?type
MINUS{ ?store wdt:P856 [] }

SERVICE wikibase:label {
  bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                       }
} ORDER BY ?typeLabel UCASE(?storeLabel)
Try it!

Wikipedia infoboxes edit

Most common properties for a type of item on a given language Wikipedia edit

Thanks to User:Piecesofuk and User:Infrastruktur for improvements.

# Most common properties (excluding external ids) for a type of item on a given Wikipedia
SELECT ?id ?idlabel (round(?count*1000/?total)/10 AS ?percent)
WITH {
  SELECT ?item WHERE {
    ?item wdt:P31/wdt:P279? wd:Q5398426 .
    ?arwp schema:about ?item ; schema:isPartOf <https://ary.wikipedia.org/>
  }
} AS %list
WITH {
  SELECT (COUNT(?item) AS ?total) WHERE {
    include %list
  }
} AS %total
WITH {
  SELECT ?id (COUNT(DISTINCT ?item) AS ?count) WHERE {
    include %list
    ?item ?p [] .
    ?id wikibase:claim ?p . FILTER(?p != p:P31)
    MINUS { ?id wikibase:propertyType wikibase:ExternalId }
  }
  GROUP BY ?id
} AS %props
WHERE {
  include %props
  include %total
  ?id rdfs:label ?idlabel . FILTER (lang(?idlabel) = "en")
}
ORDER BY DESC(?percent)
LIMIT 50
Try it!

Wikidata Graphs edit

Counts of items in subclasses of literary work edit

SELECT ?type ?typename (COUNT(?text) AS ?count)
WHERE {
?text wdt:P31 ?type.
?type wdt:P279* wd:Q7725634.
?type rdfs:label ?typename filter (lang(?typename) = "en")
} GROUP BY ?type ?typename ORDER BY DESC(?count)
LIMIT 100
Try it!

Wikidata storytelling: Shelley's Guitar edit

Optimised by User:TweetsFactsAndQueries

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q43380186 wd:Q93343 wd:Q43380245 wd:Q31561 wd:Q1302047 wd:Q47152 wd:Q86440 wd:Q692 wd:Q82133 wd:Q60643108 wd:Q56676227}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
?item1 ?prop ?item2.
?edge wikibase:directClaim ?prop ; a wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Wikidata storytelling: Wang Xianzhi and the Ashmolean edit

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q636400 wd:Q50813061 wd:Q50819534 wd:Q27147621 wd:Q559425 wd:Q15928529 wd:Q50819542 wd:Q16666 wd:Q10875944 wd:Q2047427}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
?item1 ?prop ?item2.
?edge ?dummy ?prop ; rdf:type wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Wikidata storytelling: the Shahnamah edit

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q8279 wd:Q43459 wd:Q82133 wd:Q8462 wd:Q53676578 wd:Q3147516 wd:Q553204 wd:Q20737645 wd:Q507564 wd:Q60809157 wd:Q1601879 wd:Q5943957 wd:Q1459037}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
?item1 ?prop ?item2.
?edge ?dummy ?prop ; rdf:type wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Wikidata storytelling: astrolabes edit

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel 
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q3172160 wd:Q56024100 wd:Q524289 wd:Q55867318 wd:Q524289 wd:Q6941088 wd:Q55867319 wd:Q15109492 wd:Q56867532 wd:Q1646305}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.?item1 ?prop ?item2.
?edge ?dummy ?prop ; rdf:type wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!

Wikidata storytelling: Cunningham's Law and Godwin's Law edit

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel 
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q154619 wd:Q2071976 wd:Q7637 wd:Q83 wd:Q171 wd:Q28778432 wd:Q180 wd:Q6686945}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.?item1 ?prop ?item2.
?edge ?dummy ?prop ; rdf:type wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
}
Try it!

Wikidata storytelling: the Lanchester family edit

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q233009 wd:Q55264 wd:Q18527930 wd:Q61412 wd:Q9061 wd:Q1170115 wd:Q1453055 wd:Q5541515 wd:Q5729524 wd:Q1138080 wd:Q82133 wd:Q20081025 wd:Q860807}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
?item1 ?prop ?item2.
?edge wikibase:directClaim ?prop ; a wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

Wikidata storytelling: things called "Sandwich" edit

The following query uses these:

Features: Graph (Q24515287)  View with Reasonator View with SQID

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel
WITH { SELECT ?item1 WHERE {
VALUES ?item1 {wd:Q26163 wd:Q28803 wd:Q334953 wd:Q118223 wd:Q28045325 wd:Q28045325 wd:Q3305213 wd:Q678539 wd:Q5326366 wd:Q6249175}
} } AS %item1
WITH {SELECT (?item1 AS ?item2) WHERE {INCLUDE %item1} } AS %item2
WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
?item1 ?prop ?item2.
?edge wikibase:directClaim ?prop ; a wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
OPTIONAL {?item2 wdt:P18 ?image2}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

Attempt at query-driven graph with unspecified properties edit

#defaultView:Graph
SELECT ?item1 ?image ?item1Label ?item2 ?edgeLabel WHERE {
VALUES ?target {wd:Q47152}
{?target ?prop1 ?item1} UNION {?item1 ?prop1 ?target} UNION {VALUES ?item1 {wd:Q47152} }. ?item1 wdt:P31 wd:Q5.
{?target ?prop2 ?item2} UNION {?item2 ?prop2 ?target}. ?item2 wdt:P31 wd:Q5.
?item1 ?prop ?item2.
?edge ?dummy ?prop ; rdf:type wikibase:Property
OPTIONAL {?item1 wdt:P18 ?image}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Academic disciplines edit

SELECT DISTINCT ?a ?aLabel WHERE {
?a wdt:P31/wdt:P279? wd:Q11862829. 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
} ORDER BY ?aLabel
Try it!