User:MartinPoulter/queries/collections

See also Wikidata:WikiProject_Heritage_institutions/Tools_&_tasks#Sample_Queries

Self-portraits of women: Image gridEdit

#defaultView:ImageGrid
SELECT ?p ?pLabel ?aLabel (SAMPLE(?image) AS ?img) WHERE {
?p wdt:P31 wd:Q3305213; wdt:P170 ?a; wdt:P136 wd:Q192110 ; wdt:P18 ?image. ?a wdt:P21 wd:Q6581072
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?p ?pLabel ?aLabel LIMIT 300

Try it!

How many Wikidata things have the "in collection" propertyEdit

The following query uses these:

  • Properties: collection (P195)  View with Reasonator View with SQID, end time (P582)  View with Reasonator View with SQID
    1 SELECT (COUNT(?obj) AS ?count)  WHERE {
    2 ?obj p:P195 ?s.
    3 ?s ps:P195 ?collection.
    4 MINUS { ?s pq:P582 [] }
    5 }
    
  • As of 25 November 2017: 314,221. An extra 1,150 if we allow relations that have an end date.
  • As of 2 October 2017: 464,608.
  • As of 29 August 2019: 1,092,686.

Collection sizesEdit

The following query uses these:

  • Properties: part of (P361)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, collection or exhibition size (P1436)  View with Reasonator View with SQID, applies to part (P518)  View with Reasonator View with SQID
     1 SELECT ?collection ?collectionLabel ?partofLabel ?countryLabel ?size ?partLabel WHERE {
     2 ?collection p:P1436 ?s.
     3   ?s ps:P1436 ?size
     4   OPTIONAL {?s pq:P518 ?part}
     5   OPTIONAL {?collection wdt:P361 ?partof . # Get the organisation the collection is part of
     6             MINUS{ ?partof wdt:P31 wd:Q13406463 } } # but not Wikimedia list articles
     7   OPTIONAL {?collection wdt:P17 ?country}
     8 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
     9   FILTER (?size > 100)
    10 } ORDER BY DESC(?size)
    

Oldest institution in each country that now acts as a museumEdit

SELECT DISTINCT ?countryLabel ?museum ?museumLabel (YEAR(?earliest) as ?year) WHERE {
{ SELECT ?country (MIN(?inception) as ?earliest) WHERE {
    ?museum wdt:P31/wdt:P279? wd:Q33506 ; wdt:P131?/wdt:P17 ?country; wdt:P571 ?inception
    } GROUP BY ?country }
?museum wdt:P31/wdt:P279? wd:Q33506 ; wdt:P131?/wdt:P17 ?country; wdt:P571 ?earliest.
MINUS {?country wdt:P576 []} # Exclude abolished countries like the Austrian Empire
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?countryLabel

Try it!

Number of items in Wikidata with each collection propertyEdit

The following query uses these:

  • Properties: part of (P361)  View with Reasonator View with SQID, collection (P195)  View with Reasonator View with SQID, end time (P582)  View with Reasonator View with SQID
    1 SELECT (COUNT(?obj) AS ?count) ?collection ?collectionLabel ?partofLabel WHERE {
    2 ?obj p:P195 ?s.
    3 ?s ps:P195 ?collection.
    4 MINUS { ?s pq:P582 [] }
    5 OPTIONAL { ?collection wdt:P361 ?partof }
    6 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    7 } GROUP BY ?collection ?collectionLabel ?partofLabel
    8 ORDER BY DESC(?count)
    9 LIMIT 100
    

Most common properties of objects in a given collectionEdit

The following query uses these:

Properties that items from two collections have in commonEdit

The following query uses these:

  • Properties: collection (P195)  View with Reasonator View with SQID, depicts (P180)  View with Reasonator View with SQID, creator (P170)  View with Reasonator View with SQID, time period (P2348)  View with Reasonator View with SQID, movement (P135)  View with Reasonator View with SQID, genre (P136)  View with Reasonator View with SQID, inspired by (P941)  View with Reasonator View with SQID, material used (P186)  View with Reasonator View with SQID, location of creation (P1071)  View with Reasonator View with SQID
     1 #defaultView:ScatterChart
     2 SELECT (?count1 AS ?in_Tate) (?count2 AS ?in_Smithsonian) (CONCAT(?propertyLabel,": ",?thingLabel)AS ?attribute) WHERE {
     3 { SELECT (COUNT(?obj1) AS ?count1) ?property ?thing WHERE {
     4  ?obj1 wdt:P195 wd:Q430682. #Tate
     5  VALUES ?prop1 {wdt:P180 wdt:P170 wdt:P2348 wdt:P135 wdt:P136 wdt:P941 wdt:P186 wdt:P1071}
     6  ?obj1 ?prop1 ?thing.
     7  ?property ?ref ?prop1 ; 
     8            rdf:type wikibase:Property .
     9   } GROUP BY ?property ?thing }
    10 { SELECT (COUNT(?obj2) AS ?count2) ?property ?thing WHERE {
    11  ?obj2 wdt:P195 wd:Q1192305. #Smithsonian
    12  VALUES ?prop1 {wdt:P180 wdt:P170 wdt:P2348 wdt:P135 wdt:P136 wdt:P941 wdt:P186 wdt:P1071}
    13  ?obj2 ?prop1 ?thing.
    14  ?property ?ref ?prop1 ;
    15            rdf:type wikibase:Property .
    16   } GROUP BY ?property ?thing }
    17  FILTER (?count2 >2 )
    18  FILTER (?count1 >2 )
    19 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?property rdfs:label ?propertyLabel .?thing rdfs:label ?thingLabel }
    20 }
    

Refined version of above that just focuses on artists in commonEdit

The following query uses these:

  • Properties: collection (P195)  View with Reasonator View with SQID, creator (P170)  View with Reasonator View with SQID
     1 #defaultView:ScatterChart
     2 SELECT (?count1 AS ?in_Tate) (?count2 AS ?in_NPG) ?artist WHERE {
     3 { SELECT (COUNT(?obj1) AS ?count1) ?creator WHERE {
     4  ?obj1 wdt:P195 wd:Q430682. #Tate
     5  ?obj1 wdt:P170 ?creator.
     6   } GROUP BY ?creator }
     7 { SELECT (COUNT(?obj2) AS ?count2) ?creator WHERE {
     8  ?obj2 wdt:P195 wd:Q238587. #National Portrait Gallery
     9  ?obj2 wdt:P170 ?creator.
    10   } GROUP BY ?creator }
    11  FILTER (?creator != wd:Q4233718) # exclude anonymous works
    12 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?creator rdfs:label ?artist }
    13 }
    

Artists who died before the 19th centuryEdit

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, date of death (P570)  View with Reasonator View with SQID, sex or gender (P21)  View with Reasonator View with SQID, country of citizenship (P27)  View with Reasonator View with SQID
    1 SELECT DISTINCT ?artist ?artistLabel ?genderLabel ?countryLabel (year(?death) as ?deathyear) #?birthyear ?flyear 
    2 WHERE {
    3   ?artist wdt:P31 wd:Q5 ; wdt:P106/wdt:P279? wd:Q1028181 .
    4 ?artist wdt:P570 ?death FILTER(year(?death)<1800).
    5 OPTIONAL{?artist wdt:P21 ?gender}
    6 OPTIONAL{?artist wdt:P27 ?country}
    7 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    8 } ORDER BY DESC(?deathyear)
    

Landscape art that is taller than it is wideEdit

#defaultView:ImageGrid
SELECT ?i ?iLabel ?iDescription ?collLabel ?image WHERE {
?i wdt:P31 wd:Q3305213.
  ?i wdt:P136 wd:Q191163 .
     ?i wdt:P2048 ?height.
     ?i wdt:P2049 ?width.
    FILTER (?height > ?width)
  ?i wdt:P18 ?image.
  ?i wdt:P195 ?coll.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Items of type "oil painting" that don't include oil paint as a materialEdit

SELECT ?item ?itemLabel ?itemDescription ?collectionLabel WHERE {
?item wdt:P31 wd:Q56676227
      MINUS {?item wdt:P186 wd:Q296955}
OPTIONAL {?item wdt:P195 ?collection}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

3D scan files of items from collectionsEdit

SELECT ?item ?itemLabel ?itemDescription ?model WHERE {
?item wdt:P4896 ?model; wdt:P195 [].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr" }
} ORDER BY ?itemLabel

Try it!

Depictions in common between Ashmolean Museum and Cleveland Museum of ArtEdit

SELECT ?depicted ?depictedLabel ?ashcount ?ashexample ?ashexampleLabel ?clevcount ?clevexample ?clevexampleLabel WHERE {
{SELECT ?depicted (Sample(?itemash) AS ?ashexample) (COUNT(DISTINCT ?itemash) AS ?ashcount) (sample(?itemclev) as ?clevexample) (COUNT(DISTINCT ?itemclev) AS ?clevcount) WHERE {
?itemclev wdt:P195 wd:Q657415; wdt:P180 ?depicted.
?itemash wdt:P195 wd:Q636400 ; wdt:P180 ?depicted.
  } GROUP BY ?depicted }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?ashcount + ?clevcount)

Try it!

Cleveland Museum of Art items with no "depicts" propertyEdit

#defaultView:ImageGrid
SELECT DISTINCT ?item ?itemLabel ?id ?img WHERE {
  ?item p:P217 [ps:P217 ?id; pq:P195 wd:Q657415] .
  ?item wdt:P5008 wd:Q60729883 .
  OPTIONAL { ?item wdt:P18 ?img } .
  MINUS { ?item wdt:P180 [] }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

ManuscriptsEdit

Image gallery of notable manuscripts (which have an image on Wikimedia Commons)Edit

The following query uses these:

Features: ImageGrid (Q24515278)     

 1 #defaultView:ImageGrid
 2 SELECT ?link (MIN(?image) AS ?img) ?qLabel (COUNT(DISTINCT ?sitelink) AS ?linkcount) WHERE {
 3   ?q (wdt:P31/wdt:P279*) wd:Q87167.
 4   FILTER (?q != wd:Q145780) # Exclude Dead Sea Scrolls: too broad
 5   ?sitelink schema:about ?q.
 6   ?q wdt:P18 ?image.
 7   BIND(URI(CONCAT("http://example.org/test/manuscripts/index.php?q=manuscript/",SUBSTR(STR(?q),32))) AS ?link)
 8   SERVICE wikibase:label {
 9     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
10     ?q rdfs:label ?qLabel.
11   }
12 }
13 GROUP BY ?link ?qLabel
14 ORDER BY DESC(?linkcount)
15 LIMIT 100

The most notable manuscripts and their collectionsEdit

The following query uses these:

  • Properties: instance of (P31)     , subclass of (P279)     , language of work or name (P407)     , collection (P195)     , end time (P582)     
     1 SELECT ?q ?qLabel (GROUP_CONCAT(DISTINCT ?collectionLabel; separator="; ") AS ?where) ?enwp (GROUP_CONCAT(DISTINCT ?langLabel; separator=", ") AS ?languages) ?linkcount
     2 WHERE { {SELECT ?q (COUNT(?sitelink) AS ?linkcount) WHERE {  ?q (wdt:P31/wdt:P279*) wd:Q87167. ?sitelink schema:about ?q }
     3    GROUP BY ?q  }
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5       MINUS {?s ps:P195 wd:Q1322278 }
     6 OPTIONAL{ ?q wdt:P407 ?lang }
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
     9     ?q rdfs:label ?qLabel. ?collection rdfs:label ?collectionLabel . ?lang rdfs:label ?langLabel
    10   }
    11  OPTIONAL{?enwp schema:about ?q ; schema:isPartOf <https://en.wikipedia.org/> }
    12  # other props: inventory number; part of ; full work (P953); Commons cat; described at (P973)
    13 }
    14 GROUP BY ?q ?qLabel ?enwp ?linkcount
    15 ORDER BY DESC(?linkcount)
    

The most notable manuscripts available via IIIF, with IIIF linksEdit

SELECT ?q ?qLabel (GROUP_CONCAT(DISTINCT ?collectionLabel; separator="; ") AS ?where)
(URI(CONCAT('https://tools.wmflabs.org/mirador/?manifest=', STR(?iiif))) AS ?iiiflink)
WHERE { 
  ?q (wdt:P31/wdt:P279*) wd:Q87167; wdt:P6108 ?iiif; wikibase:sitelinks ?sitecount FILTER(?sitecount > 0)
?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
      MINUS {?s ps:P195 wd:Q1322278 }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?q rdfs:label ?qLabel. ?collection rdfs:label ?collectionLabel
    }
}
GROUP BY ?q ?qLabel ?iiif ?sitecount
ORDER BY DESC(?sitecount)

Try it!

Notable manuscripts and their collections (full query)Edit

The following query uses these:

  • Properties: instance of (P31)     , subclass of (P279)     , image (P18)     , language of work or name (P407)     , collection (P195)     , end time (P582)     , inventory number (P217)     
     1 SELECT ?q ?qLabel (GROUP_CONCAT(DISTINCT ?collplusinv; separator=" !!! ") AS ?where) (GROUP_CONCAT(DISTINCT ?lang; separator=" ") AS ?languages) ?linkcount (SAMPLE(?image) AS ?image)
     2 WHERE { {SELECT ?q (COUNT(?sitelink) AS ?linkcount) WHERE { ?q (wdt:P31/wdt:P279*) wd:Q87167. OPTIONAL {?sitelink schema:about ?q} }
     3    GROUP BY ?q  }
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5       MINUS {?s ps:P195 wd:Q1322278 }
     6 OPTIONAL{ ?s pq:P217 ?inventory}
     7 OPTIONAL{ ?q wdt:P18 ?image }
     8 BIND( IF(BOUND(?inventory), CONCAT(STR(?collection)," ",?inventory), STR(?collection)) AS ?collplusinv).
     9  SERVICE wikibase:label {
    10    bd:serviceParam wikibase:language "en,fr,it,de,es,ru,bg,ca,cs,nl,zh,ja".
    11    ?q rdfs:label ?qLabel.
    12  }
    13 OPTIONAL{ ?q wdt:P407 ?lang }
    14 # other props: part of, exemplar
    15 }
    16 GROUP BY ?q ?qLabel ?linkcount
    17 ORDER BY DESC(?linkcount)
    

Collections of manuscriptsEdit

The following query uses these:

  • Properties: instance of (P31)     , subclass of (P279)     , official website (P856)     , collection (P195)     , end time (P582)     
     1 SELECT ?collection ?l (GROUP_CONCAT(DISTINCT ?officialweb) AS ?webs) (COUNT(DISTINCT ?q) AS ?mcount)
     2 WHERE {
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection. MINUS {?s pq:P582 []}.
     5 MINUS { ?s ps:P195 wd:Q1322278 }
     6 OPTIONAL{ ?collection wdt:P856 ?officialweb } 
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "en".
     9 ?collection rdfs:label ?l
    10   }
    11 }
    12 GROUP BY ?collection ?l
    13 ORDER BY UCASE(?l)
    

Languages of manuscriptsEdit

The following query uses these:

Top ten languages by number of manuscriptsEdit

SELECT (SUBSTR(STR(?lang),32) AS ?wd) (COUNT(DISTINCT ?q) AS ?mcount)
WHERE {
?q (wdt:P31/wdt:P279*) wd:Q87167.
?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
MINUS { ?s ps:P195 wd:Q1322278 }
?q wdt:P407 ?lang 
}
GROUP BY ?lang
ORDER BY DESC(?mcount)
LIMIT 10

Try it!

Materials used in manuscriptsEdit

The following query uses these:

  • Properties: instance of (P31)     , subclass of (P279)     , material used (P186)     , collection (P195)     , end time (P582)     
     1 SELECT ?material ?l ?d (COUNT(DISTINCT ?q) AS ?mcount)
     2 WHERE {
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5 MINUS { ?s ps:P195 wd:Q1322278 }
     6 ?q wdt:P186 ?material
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "en".
     9     ?material rdfs:label ?l; schema:description ?d
    10   }
    11 }
    12 GROUP BY ?material ?l ?d
    

Map of manuscript collectionsEdit

The following query uses these:

Features: Map (Q24515275)     

 1 #defaultView:Map
 2 SELECT ?link ?collectionLabel ?coords
 3 WHERE {
 4 {SELECT DISTINCT ?collection ?coords WHERE {?q (wdt:P31/wdt:P279*) wd:Q87167;
 5   wdt:P195 ?collection .
 6 ?collection wdt:P625 ?coords.
 7 } }
 8 BIND (URI(CONCAT("/collection/",SUBSTR(STR(?collection),32))) AS ?link).
 9 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
10 }

Manuscripts lacking a collectionEdit

The following query uses these:

  • Properties: instance of (P31)     , subclass of (P279)     , collection (P195)     
     1 SELECT DISTINCT ?q ?qLabel ?qDescription ?enwp 
     2 WHERE { 
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.   
     4 MINUS { ?q wdt:P195 []}
     5   SERVICE wikibase:label {
     6     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
     7   }
     8  OPTIONAL{?enwp schema:about ?q ; schema:isPartOf <https://en.wikipedia.org/> }
     9 }
    10 ORDER BY DESC(?qLabel)
    

Objects with "instance of papyrus" (which shouldn't be the case)Edit

SELECT * WHERE {
?item wdt:P31 wd:Q125576
}

Try it!

Bodleian things and their online digitizationsEdit

SELECT ?thing ?thingLabel ?inv ?url WHERE {
VALUES ?in {wd:Q82133 wd:Q2210813} # Bodleian and Sackler
?thing p:P195 ?s; wdt:P953 ?url FILTER(CONTAINS(STR(?url),"ox.ac.uk")).
?s ps:P195 ?in
OPTIONAL { ?s pq:P217 ?inv }
MINUS {?thing wdt:P1433 []}
MINUS {?thing wdt:P361 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?thingLabel

Try it!

Bodleian items with no image and no Commons categoryEdit

SELECT ?item ?itemLabel ?url WHERE {
VALUES ?in {wd:Q82133 wd:Q2210813} # Bodleian and Sackler
?item wdt:P195 ?in; wdt:P953 ?url
MINUS {?item wdt:P18 []}
MINUS {?item wdt:P373 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Ashmolean MuseumEdit

Things in the collection of the Ashmolean museumEdit

SELECT ?type ?typeLabel (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400;
      wdt:P31 ?type.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?type ?typeLabel ORDER BY DESC(?count)

Try it!

Creators: comparison of Ashmolean items versus items in other GLAMsEdit

SELECT DISTINCT ?creator ?creatorLabel ?creatorDescription ?enwp ?ash_items (COUNT(?other) as ?other) WHERE {
{ SELECT ?creator ?enwp (COUNT(?item) AS ?ash_items) WHERE {
  ?item wdt:P195 wd:Q636400; # collection: Ashmolean
 wdt:P170 ?creator FILTER (?creator != wd:Q4233718) # Exclude anonymous
  OPTIONAL { ?enwp schema:about ?creator; schema:isPartOf <https://en.wikipedia.org/> }
  } GROUP BY ?creator ?enwp
 }
?other wdt:P170 ?creator MINUS {?other wdt:P195 wd:Q636400} # objects by same creator but not in Ashmolean
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?creator ?creatorLabel ?creatorDescription ?enwp ?ash_items
ORDER BY DESC(?ash_items) DESC(?other)

Try it!

People associated with Ashmolean itemsEdit

SELECT ?person ?personLabel ?personDescription (SAMPLE(?image) AS ?img) (COUNT(?item) AS ?count) (YEAR(SAMPLE(?time)) AS ?year) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item ?prop ?person.
?person wdt:P31 wd:Q5.
OPTIONAL {?person wdt:P18 ?image}
OPTIONAL {?person wdt:P569 ?birth}
OPTIONAL {?person wdt:P1317 ?fl}
OPTIONAL {?person wdt:P2348/wdt:P580 ?erastart}
BIND(IF(BOUND(?birth), ?birth, IF(BOUND(?fl), ?fl, ?erastart) ) AS ?time). 
SERVICE wikibase:label {bd:serviceParam wikibase:language "en"}
} GROUP BY ?person ?personLabel ?personDescription ORDER BY ?year

Try it!

Artists in the Ashmolean with entries in Benezit Dictionary of ArtistsEdit

SELECT ?artist ?artistLabel (URI(CONCAT("http://oxfordindex.oup.com/view/10.1093/benz/9780199773787.article.",?benezit)) AS ?benezit_link) (COUNT(?work) AS ?count) WHERE {
?work wdt:P195 wd:Q636400; wdt:P170 ?artist FILTER (!ISBLANK(?artist)) .
?artist wdt:P2843 ?benezit
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?artist ?artistLabel ?benezit
ORDER BY ?artistLabel

Try it!

timeline of Ashmolean artists with links to Benezit

Getty Union List of Artist Names links for Ashmolean artistsEdit

SELECT ?artist ?artistLabel (URI(CONCAT("http://vocab.getty.edu/page/ulan/",?getty_id)) AS ?getty_link) (COUNT(?work) AS ?count) WHERE {
?work wdt:P195 wd:Q636400; wdt:P170 ?artist FILTER (!ISBLANK(?artist)) .
?artist wdt:P245 ?getty_id
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?artist ?artistLabel ?getty_id
ORDER BY ?artistLabel

Try it!

Languages of Wikipedia articles about Ashmolean artistsEdit

SELECT ?languageLabel (COUNT(?sitelink) AS ?count) WITH { SELECT DISTINCT ?artist { ?work wdt:P195 wd:Q636400; wdt:P170 ?artist FILTER (!ISBLANK(?artist)) } } AS %artists WHERE {
INCLUDE %artists.
?sitelink schema:about ?artist; schema:inLanguage ?lang FILTER (CONTAINS(STR(?sitelink), "wikipedia."))
?language wdt:P218 ?lang.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?languageLabel
ORDER BY DESC(?count)

Try it!

Things depicted (but not places)Edit

SELECT ?person ?personLabel ?personDescription (SAMPLE(?image) AS ?img) (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item wdt:P180 ?person.
MINUS {?person wdt:P625 []}
OPTIONAL {?person wdt:P18 ?image}
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". }
} GROUP BY ?person ?personLabel ?personDescription ORDER BY UCASE(?personLabel)

Try it!

Locations associated with Ashmolean itemsEdit

#defaultView:Map{"hide": ["?latlong", "?layer"]}
SELECT (URI(CONCAT("http://glam-discovery.bodleian.ox.ac.uk/location/",SUBSTR(STR(?place),32) ) ) as ?link) ?placeX ?placeLabel ?layer (SAMPLE(?coords) AS ?latlong)
WHERE {
?item wdt:P195 wd:Q636400;
    wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
VALUES ?property {wd:P180 wd:P1071} # wdt:P921 wdt:P189 wdt:P138
?property wikibase:directClaim ?prop.
?item ?prop ?place.
?place wdt:P625 ?coords.
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". 
?property rdfs:label ?layer. ?place rdfs:label ?placeLabel; schema:description ?placeX}
} GROUP BY ?place ?placeLabel ?placeX ?layer

Try it!

Ashmolean items associated with a given person or locationEdit

SELECT ?prop ?item ?itemLabel ?inventory (GROUP_CONCAT(?typeLabel; separator=", ") AS ?types) ?from (YEAR(?latest) AS ?to) ?precision WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
?item ?prop wd:Q48129717; wdt:P31 ?type.
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
OPTIONAL {?item p:P571/psv:P571 [ wikibase:timePrecision ?precision; wikibase:timeValue ?year ] }
BIND(IF (BOUND(?earliest), YEAR(?earliest), YEAR(?year)) AS ?from)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
?item rdfs:label ?itemLabel. ?type rdfs:label ?typeLabel }
} GROUP BY ?prop ?item ?itemLabel ?inventory ?from ?latest ?precision
ORDER BY DESC(?prop) ?from ?to

Try it!

Ashmolean people associated with a given location or eraEdit

SELECT ?person ?personLabel ?personDescription (SAMPLE(?image) AS ?img) (YEAR(SAMPLE(?time)) AS ?year) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url), "http://jameelcentre") ).
?item ?prop ?person.
?person wdt:P31 wd:Q5.
?person ?prop2 wd:Q1490.
OPTIONAL {?person wdt:P18 ?image}
OPTIONAL {?person wdt:P569 ?birth}
OPTIONAL {?person wdt:P1317 ?fl}
OPTIONAL {?person wdt:P2348/wdt:P580 ?erastart}
BIND(IF(BOUND(?birth), ?birth, IF(BOUND(?fl), ?fl, ?erastart) ) AS ?time). 
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
} GROUP BY ?person ?personLabel ?personDescription ORDER BY ?year

Try it!

Locations associated with a given personEdit

SELECT DISTINCT (SUBSTR(STR(?place),32) as ?link) ?propertyLabel ?placeLabel
WHERE {
wd:Q198984 ?prop ?place. ?place wdt:P625 [].
?property ?ref ?prop; rdf:type wikibase:Property.
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
}

Try it!

Ten nearest places to a placeEdit

SELECT DISTINCT (SUBSTR(STR(?place),32) as ?link) ?placeLabel
WHERE {
wd:Q1191 wdt:P625 ?loc2. #Starting point
{ SELECT DISTINCT ?place ?coords WHERE 
 {?item wdt:P195 wd:Q636400;
    wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
VALUES ?property {wd:P180 wd:P1071}
?property wikibase:directClaim ?prop.
?item ?prop ?place.
?place wdt:P625 ?coords
 } }
BIND(geof:distance(?coords, ?loc2) AS ?distNum).
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". 
?place rdfs:label ?placeLabel}
} ORDER BY ?distNum OFFSET 1 LIMIT 10

Try it!

Materials of things in the Ashmolean collectionEdit

This is used to make materials.json

SELECT (SUBSTR(STR(?material), 32) as ?material) ?materialLabel ?materialDescription (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P186 ?material;
wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} GROUP BY ?material ?materialLabel ?materialDescription ORDER BY UCASE(?materialLabel)

Try it!

Ashmolean items for a given materialEdit

SELECT ?item ?itemLabel ?inventory (GROUP_CONCAT(?typeLabel; separator=", ") AS ?types) (YEAR(?earliest) AS ?from) (YEAR(?latest) AS ?to) WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
?item wdt:P186 wd:Q37681; wdt:P31 ?type;
wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".
?item rdfs:label ?itemLabel. ?type rdfs:label ?typeLabel}
} GROUP BY ?item ?itemLabel ?inventory ?earliest ?latest
ORDER BY ?from ?to ?itemLabel

Try it!

Types of things in the Ashmolean collectionEdit

used to make types.json

SELECT (SUBSTR(STR(?type), 32) as ?type) ?typeLabel ?typeDescription (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P31 ?type; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?type ?typeLabel ?typeDescription ORDER BY UCASE(?typeLabel)

Try it!

Items of a given typeEdit

SELECT ?item ?itemLabel ?inventory (YEAR(?earliest) AS ?from) (YEAR(?latest) AS ?to) WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
?item wdt:P31 wd:Q1066288; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .
?item rdfs:label ?itemLabel }
} ORDER BY ?from ?to ?itemLabel

Try it!

Ashmolean items without a labelEdit

As of 31 March 2018, gives zero results.

SELECT ?item WHERE {
?item wdt:P195 wd:Q636400.
MINUS {?item rdfs:label []}
}

Try it!

Ashmolean items without no inception date and no time periodEdit

SELECT ?item ?inventory WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
MINUS {?item wdt:P571 []}
MINUS {?item wdt:P2348 []}
}

Try it!

Ashmolean things named "Figure of " but with no depiction propertyEdit

Also includes "Standing figure of...", "Seated figure of..."

SELECT ?item ?itemLabel ?url WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url
MINUS {?item wdt:P180 []}
?item rdfs:label ?itemLabel filter( lang(?itemLabel)="en" ) filter( CONTAINS(?itemLabel, "igure of ") )
}

Try it!

Jameel items ordered by number of statementsEdit

SELECT ?item ?itemLabel ?url ?count WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item wikibase:statements ?count.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?count)
LIMIT 20

Try it!

Count of links from Jameel items to items that have a locationEdit

SELECT (COUNT(?loc) as ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item ?prop ?loc. ?loc wdt:P625 [] FILTER (?loc != wd:Q636400)
}

Try it!

Wikipedia pages about Ashmolean items in languages other than EnglishEdit

SELECT ?itemLabel ?inv ?languageLabel ?sitelink WHERE {
?item wdt:P195 wd:Q636400; wdt:P217 ?inv # items in the Ashmolean and get their inventory number
      FILTER (?item != wd:Q1249435) .    # exclude Oxyrhynchus Papyri
?sitelink schema:about ?item;            # Wikimedia links (usually Wikipedia articles)
          schema:inLanguage ?lang FILTER (?lang != 'en') FILTER (?lang != 'en-simple') . # exclude English language
?language wdt:P305 ?lang                 # convert two-letter code to language item
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?inv

Try it!

web.ashmolean.org items without an Ashmolean Museum IDEdit

SELECT ?item ?itemLabel ?itemDescription ?url WHERE {
?item wdt:P195 wd:Q636400.
?item wdt:P973 ?url FILTER( CONTAINS(STR(?url), "www.ashmolean.org") )
   MINUS {?item wdt:P6610 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Things in the Ashmolean that have gold as their only materialEdit

Should give no results (no results as of 19 May 2019)

SELECT ?item ?url WHERE {
?item wdt:P195 wd:Q636400; # collection: Ashmolean
wdt:P31 wd:Q3305213; # type: painting
wdt:P186 wd:Q897  # material: gold
MINUS {?item wdt:P186 ?mat FILTER (?mat != wd:Q897) } # no non-gold material
OPTIONAL {?item wdt:P973 ?url}
}

Try it!

Things with two different Ashmolean Museum identifiers (should give no results)Edit

SELECT * WHERE {
?i wdt:P6610 ?id1; wdt:P6610 ?id2 FILTER (?id1 > ?id2)
}

Try it!

External links from Ashmolean Museum's English Wikipedia articleEdit

Query provided by Lucas Werkmeister

SELECT ?extlink WHERE {
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Generator";
                    wikibase:endpoint "en.wikipedia.org";
                    mwapi:generator "allpages";
                    mwapi:gapfrom "Ashmolean_Museum";
                    mwapi:gapto "Ashmolean_Museum";
                    mwapi:prop "extlinks".
    ?extlink wikibase:apiOutput "extlinks/el/text()".
  }
}

Try it!

Links to a particular domain from the Wikipedia biographies of artists in a given collectionEdit

SELECT ?artistpage ?extlink WHERE {
{SELECT DISTINCT ?name ?artistpage WHERE {
    ?item wdt:P195 wd:Q636400; wdt:P170 ?artist.   # Artists in the Ashmolean
    ?artistpage schema:about ?artist;
                schema:isPartOf <https://en.wikipedia.org/>;   # ENWP articles about them
                schema:name ?name     # Title of article
}
 }
OPTIONAL {SERVICE wikibase:mwapi { # External links from each article
    bd:serviceParam wikibase:api "Generator";
           wikibase:endpoint "en.wikipedia.org";
           mwapi:generator "allpages";
           mwapi:gapfrom ?name;
           mwapi:gapto ?name;
           mwapi:prop "extlinks".
    ?extlink wikibase:apiOutput "extlinks/el/text()".
  }
    FILTER CONTAINS(?extlink, "rkd.nl")
 }
} ORDER BY ?artistpage

Try it!

Wikipedia articles about Ashmolean items, their links to the Ashmolean web site, and candidate links from WikidataEdit

Doesn't work yet as MWAPI doesn't return enough external links. Phabricator report

SELECT ?itempage ?extlink ?url ?ash_id WHERE {
{SELECT DISTINCT ?name ?item ?itempage WHERE {
    ?item wdt:P195 wd:Q636400.   # items in the Ashmolean
    ?itempage schema:about ?item;
         schema:isPartOf <https://en.wikipedia.org/>;   # ENWP articles about them
         schema:name ?name     # Title of article
}
 }
OPTIONAL {SERVICE wikibase:mwapi { # External links from each article
    bd:serviceParam wikibase:api "Generator";
         wikibase:endpoint "en.wikipedia.org";
         mwapi:generator "allpages";
         mwapi:gapfrom ?name;
         mwapi:gapto ?name;
         mwapi:prop "extlinks";
         mwapi:ellimit 50 .
    ?extlink wikibase:apiOutput "extlinks/el/text()".
  }
    FILTER CONTAINS(?extlink, "ashmolean.org")
 }
OPTIONAL {?item wdt:P973 ?url FILTER CONTAINS(STR(?url), "ashmolean.org")
                }
OPTIONAL {?item wdt:P6610 ?ash_id}
} ORDER BY ?itempage

Try it!

External links from Commons File:pagesEdit

Thanks to Lucas Werkmeister again

SELECT ?image ?extlink WHERE {
  wd:Q4656096 wdt:P18 ?image.
  BIND(STRAFTER(STR(?image), "FilePath/") AS ?encoded_name)
  BIND(wikibase:decodeUri(?encoded_name) AS ?name)
  OPTIONAL { SERVICE wikibase:mwapi { # External links from each image
    bd:serviceParam wikibase:api "Generator";
                    wikibase:endpoint "commons.wikimedia.org";
                    mwapi:generator "allimages";
                    mwapi:gaifrom ?name;
                    mwapi:gaito ?name;
                    mwapi:prop "extlinks";
                    mwapi:ellimit "500".
    ?extlink wikibase:apiOutput "extlinks/el/text()".
  } }
} ORDER BY ?name

Try it!

Connections from Ashmolean Museum items to Japan Search entitiesEdit

SELECT DISTINCT ?work ?workLabel ?propertyLabel ?thingLabel (?jps AS ?japan_search_id) WHERE {
?thing wdt:P6698 ?jps FILTER (!CONTAINS(?jps, "nmoa-")).
VALUES ?prop {wdt:P170 wdt:P180}
?work wdt:P195 wd:Q636400; ?prop ?thing.
  ?property ?ref ?prop ;
          rdf:type wikibase:Property 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?thingLabel

Try it!

Oxford Collections overviewEdit

Things connected to Oxford collection itemsEdit

SELECT (SUBSTR(STR(?thing),32) AS ?q) (SUBSTR(STR(?prop),37) as ?p) (SUBSTR(STR(?item),32) AS ?itemq) ?itemLabel ?fullwork (SUBSTR(STR(?coll),32) as ?collq) ?inventory ?url (GROUP_CONCAT(SUBSTR(STR(?artist),32);separator=" ") AS ?artists)
(GROUP_CONCAT(?typeLabel; separator=", ") AS ?types) ?from (YEAR(?latest) AS ?to) ?precision WHERE {
VALUES ?coll {wd:Q636400 wd:Q82133 wd:Q1456119 wd:Q6941088} # Ashmolean, Bodleian, PRM, MHS
?item p:P195 [ps:P195 ?coll; pq:P217 ?inventory].
VALUES ?prop {wdt:P180 wdt:P170 wdt:P1774 wdt:P138} # depicted, creator, school of, named after
?item ?prop ?thing; wdt:P31 ?type.
OPTIONAL {?item wdt:P973 ?url FILTER(CONTAINS(STR(?url), ".ox.ac.uk")|| CONTAINS(STR(?url), "ashmolean.org") )}
OPTIONAL {?item wdt:P953 ?fullwork FILTER(CONTAINS(STR(?fullwork), ".ox.ac.uk") || CONTAINS(STR(?fullwork), "ashmolean.org") )}
FILTER (BOUND(?fullwork) || BOUND(?url) )
OPTIONAL {?item wdt:P170 ?artist}
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
OPTIONAL {?item p:P571/psv:P571 [ wikibase:timePrecision ?precision; wikibase:timeValue ?year ] }
BIND(IF (BOUND(?earliest), YEAR(?earliest), YEAR(?year)) AS ?from)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .
?item rdfs:label ?itemLabel. ?type rdfs:label ?typeLabel }
} GROUP BY ?thing ?prop ?item ?itemLabel ?fullwork ?inventory ?url ?coll ?from ?latest ?precision
ORDER BY DESC(?prop) ?from ?to

Try it!

Things described at an Oxford web address but aren't in the collections that have shared with WikidataEdit

SELECT DISTINCT ?item ?itemLabel ?itemDescription  WHERE {
{?item wdt:P973 ?url FILTER (STRSTARTS(STR(?url), ".ox.ac.uk")) } 
UNION {?item wdt:P953 ?fullwork FILTER (CONTAINS(STR(?fullwork), ".ox.ac.uk")) }
?item wdt:P195 ?coll FILTER( ?coll NOT IN (wd:Q636400, wd:Q82133, wd:Q1456119, wd:Q6941088, wd:Q52556635) ).
SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}

Try it!

Pitt Rivers MuseumEdit

Unreferenced statements about things in the Pitt Rivers MuseumEdit

SELECT (SUBSTR(STR(?item),32) AS ?wdq) (SUBSTR(STR(?prop),32) AS ?wdp) ?object ?url WHERE {
?item wdt:P195 wd:Q1456119.
?item wdt:P973 ?url FILTER CONTAINS(STR(?url), "ox.ac.uk"). 
?item ?p ?statement.
  ?prop wikibase:claim ?p; wikibase:statementProperty ?ps  FILTER (?prop != wd:P973) FILTER (?prop != wd:P953)
        FILTER (?prop != wd:P18) FILTER (?prop != wd:P571).
  ?statement ?ps ?object .
  FILTER NOT EXISTS {?statement prov:wasDerivedFrom ?derivedFrom}
} ORDER BY ?item

Try it!

Things whose archives are in the Pitt-Rivers MuseumEdit

As of April 2019, 50 out of 79 (one appears twice because of two VIAF IDs)

SELECT ?person ?personLabel ?personDescription (URI(CONCAT("https://viaf.org/viaf/", ?viaf)) AS ?viaf_link)
(URI(CONCAT("https://doi.org/10.1093/ref:odnb/", ?odnb)) AS ?odnb_link) ?image ?url
WHERE {
?person p:P485 [ps:P485 wd:Q1456119; pq:P973 ?url] 
OPTIONAL {?person wdt:P214 ?viaf}
OPTIONAL {?person wdt:P18 ?image}
OPTIONAL {?person wdt:P1415 ?odnb}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

Try it!

Image gallery of people whose archives are in the Pitt-Rivers MuseumEdit

#defaultView:ImageGrid{"hide": ["?image"]}
SELECT ?image ?personDescription ?personLabel ?prmlink
WHERE {
?person p:P485 [ps:P485 wd:Q1456119; pq:P973 ?prmlink].
?person wdt:P18 ?image
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

Try it!

Histropedia timeline of people connected to the PRM, colour-coded by gender

Historic ChinaEdit

See also Wikidata:WikiProject_East_Asia/China_Biographical_Database_import

Things from dynasties of the imperial era, with their collections and shelfmarksEdit

The following query uses these:

  • Properties: instance of (P31)     , time period (P2348)     , country (P17)     , country of origin (P495)     , collection (P195)     , material used (P186)     , inventory number (P217)     
     1 SELECT ?dynastyLabel ?thing ?thingLabel (GROUP_CONCAT(DISTINCT ?typel; separator=", ") AS ?what) (GROUP_CONCAT(DISTINCT ?matl; separator=", ") AS ?materials) ?thingDescription ?collectionLabel ?inventoryNo WHERE {
     2 ?dynasty wdt:P31 wd:Q50068795.
     3 VALUES ?prop {wdt:P2348 wdt:P17 wdt:P495}.
     4 ?thing ?prop ?dynasty;
     5        wdt:P31 ?type;
     6        wdt:P195 ?collection.
     7  ?type rdfs:label ?typel FILTER(lang(?typel) = "en").
     8 OPTIONAL {?thing wdt:P186 ?material. ?material rdfs:label ?matl FILTER(lang(?matl) = "en") }.
     9 OPTIONAL {?thing wdt:P217 ?inventoryNo }
    10 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    11 } GROUP BY ?dynastyLabel ?thing ?thingLabel?thingDescription ?collectionLabel ?inventoryNo
    12 ORDER BY ?dynastyLabel
    

Timeline of states of Imperial periodEdit

The following query uses these:

Time periodsEdit

Historic periods and corresponding numbers of things in collectionsEdit

The following query uses these:

  • Properties: time period (P2348)     , collection (P195)     , end time (P582)     
     1 SELECT ?period ?periodLabel ?periodDescription (COUNT(?q) AS ?mcount)
     2 WHERE {
     3 ?q wdt:P2348 ?period.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5   SERVICE wikibase:label {
     6     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
     7   }
     8  OPTIONAL{?enwp schema:about ?collection; schema:isPartOf <https://en.wikipedia.org/> }
     9 }
    10 GROUP BY ?period ?periodLabel ?periodDescription
    11 ORDER BY DESC(?mcount)
    

History of JapanEdit

Periods of Japanese history and what they were named afterEdit

SELECT ?era ?eraLabel (YEAR(?start_time) AS ?start) (YEAR(?end_time) AS ?end) ?namedLabel ?namedDescription WHERE {
?era wdt:P31 wd:Q11514315; wdt:P361 wd:Q130436; # eras of the history of Japan
  wdt:P580 ?start_time.
#MINUS { ?era wdt:P2348/wdt:P361 wd:Q130436 } # exclude sub-eras
MINUS {?era wdt:P2348 []}
OPTIONAL { ?era wdt:P582 ?end_time }
OPTIONAL { ?era wdt:P138 ?named }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?start DESC(?end)

Try it!

Periods of Japanese history and calendar eras within themEdit

SELECT ?era ?eraLabel (YEAR(?start_time) AS ?start) (YEAR(?end_time) AS ?end) ?subera ?suberaLabel 
 (YEAR(?sub_start_time) AS ?sub_start) (YEAR(?sub_end_time) AS ?sub_end) WHERE {
?era wdt:P31  wd:Q11514315; wdt:P361 wd:Q130436; # eras of the history of Japan
  wdt:P580 ?start_time.
MINUS { ?era wdt:P2348 []} # exclude sub-eras
OPTIONAL { ?era wdt:P582 ?end_time }
OPTIONAL { ?subera wdt:P2348 ?era; wdt:P361 wd:Q130436; wdt:P580 ?sub_start_time;
  wdt:P582 ?sub_end_time }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?start DESC(?end)

Try it!

Japan SearchEdit

Numbers of language labels for things with a Japan Search Name IDEdit

SELECT ?languageLabel ?count WHERE {
{SELECT ?langcode (COUNT(?label) as ?count) WHERE {
?thing wdt:P6698 ?jpsid; rdfs:label ?label.
BIND(lang(?label) AS ?langcode)
} GROUP BY ?langcode }
?language wdt:P218 ?langcode
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?count)

Try it!

Missing labels and descriptionsEdit

Paintings with no English description but a known artist labelEdit

SELECT ?item ("Den" AS ?den) (CONCAT("painting by ", ?creatorLabel) as ?toadd) WHERE {
?item wdt:P31 wd:Q3305213; wdt:P170 ?creator FILTER(?creator != wd:Q4233718) # exclude Anonymous
MINUS {?item wdt:P31 ?other FILTER(?other != wd:Q3305213) } # painting is only type
MINUS {?item schema:description ?engdesc FILTER (lang(?engdesc)="en") } # No English description
?creator rdfs:label ?creatorLabel FILTER (lang(?creatorLabel)="en") # Artist label in English is known
}

Try it!

Paintings with no English label but a Commons CategoryEdit

SELECT ?item ?category WHERE {
?item wdt:P31 wd:Q3305213; wdt:P373 ?category
MINUS{ ?item rdfs:label ?itemLabel FILTER (lang(?itemLabel)="en") }
}

Try it!

Books with a title in a given language but not a label in that languageEdit

SELECT ?item ?lang ?title WHERE {
?item wdt:P31/wdt:P279* wd:Q571 ; # Q571 for book
      wdt:P1476 ?title .
  BIND(LANG(?title) as ?lang) FILTER (?lang != "und")
FILTER (NOT EXISTS{ ?item rdfs:label ?itemLabel. FILTER(lang(?itemLabel) = ?lang) })
}

Try it!

Wikidata maintenanceEdit

How many items have an inventory number but no collection?Edit

The following query uses these:

How many items have an inventory number with a collection in a qualifier but no collection?Edit

The following query uses these:

As of 25 November 2017, 358

Collections and inventory numbers of items an inventory number with a collection in a qualifier but no collectionEdit

The following query uses these:

Semantic searchEdit

SynonymsEdit

SELECT DISTINCT ?name WHERE {
VALUES ?rel {rdfs:label skos:altLabel}
VALUES ?rel2 {rdfs:label skos:altLabel}
?target ?rel "Confucius"@en;
 ?rel2 ?name FILTER ( lang(?name)="en" )
}

Try it!

Names for types of coinEdit

SELECT DISTINCT ?name WHERE {
 ?sub wdt:P279+/rdfs:label "coin"@en.
 {?sub rdfs:label ?name} UNION {?sub skos:altLabel ?name} FILTER (lang(?name)="en")
  FILTER ( !CONTAINS(?name, "coin") )
}

Try it!

Things semantically related to a given topicEdit

SELECT DISTINCT ?related ?relatedLabel ?relatedDescription WHERE {
VALUES ?target {wd:Q42}
{ ?target ?prop ?related } UNION { ?related ?prop ?target }
filter (CONTAINS(STR(?related),'/entity/Q') ).
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY UCASE(?relatedLabel)

Try it!

Data-driven semantic clusteringEdit

#defaultView:Graph
SELECT ?item1 ?item1Label ?item2 ?item2Label WHERE {
VALUES ?item1Label {"Congressional Black Caucus"@en
"Barack Obama"@en
"Michelle Obama"@en
"University of Chicago"@en
"Time Person of the Year"@en
"Democratic Party"@en
"White House"@en
"Hillary Clinton"@en
"Aragorn"@en
"C. S. Lewis"@en
"J. R. R. Tolkien"@en
"University of Oxford"@en
"World War I"@en
"Battle of the Somme"@en
"British Army"@en
"The Lord of the Rings"@en}
VALUES ?item2Label {"Congressional Black Caucus"@en
"Barack Obama"@en
"Michelle Obama"@en
"University of Chicago"@en
"Time Person of the Year"@en
"Democratic Party"@en
"White House"@en
"Hillary Clinton"@en
"Aragorn"@en
"C. S. Lewis"@en
"J. R. R. Tolkien"@en
"University of Oxford"@en
"World War I"@en
"Battle of the Somme"@en
"British Army"@en
"The Lord of the Rings"@en}
  ?item1 rdfs:label ?item1Label.
  ?item2 rdfs:label ?item2Label.
  ?item1 ?prop ?item2
}

Try it!


AstrolabesEdit

All astrolabes (and parts), with collection and creatorEdit

SELECT ?collectionLabel ?inv ?url ?creatorLabel WHERE {
?item wdt:P31/wdt:P361? wd:Q164992.
?item wdt:P195 ?collection; wdt:P217 ?inv.
OPTIONAL{?item wdt:P170 ?creator}
OPTIONAL {?item wdt:P973 ?url}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?creatorLabel

Try it!

Map of locations of Astrolabe originEdit

#defaultView:Map{"hide": ["?coords"]}
SELECT ?loc ?locLabel ?coords (COUNT(?item) as ?count) WHERE {
?item wdt:P31/wdt:P361? wd:Q164992.
?item wdt:P1071 ?loc. ?loc wdt:P625 ?coords.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?loc ?locLabel ?coords

Try it!

Timeline of AstrolabesEdit

#defaultView:Timeline{"hide": "?inception"}
SELECT ?item (?thingLabel as ?itemLabel) ?d ?collectionLabel ?inception WHERE {
?thing wdt:P31 wd:Q164992; wdt:P195 ?collection; wdt:P217 ?d; wdt:P571 ?inception
OPTIONAL {?thing wdt:P973 ?url}
BIND (IF(BOUND(?url),?url, URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", substr(str(?thing),32))) ) AS ?item)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?thing rdfs:label ?thingLabel. ?collection rdfs:label ?collectionLabel}
}

Try it!

Creators with Reasonator linksEdit

SELECT DISTINCT (URI(CONCAT("https://tools.wmflabs.org/reasonator/?q=", SUBSTR(STR(?creator),32) )) as ?reasonator) ?creatorLabel
(GROUP_CONCAT(DISTINCT ?locLabel; separator=", ") AS ?locations) ?countryLabel (COUNT(?item) AS ?count) WHERE {
?item wdt:P31/wdt:P361? wd:Q164992.
VALUES ?rel {wdt:P170 wdt:P1774}
?item ?rel ?creator
OPTIONAL {?creator wdt:P27 ?country }
OPTIONAL {?creator wdt:P937 ?loc }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                        ?loc rdfs:label ?locLabel. ?creator rdfs:label ?creatorLabel. ?country rdfs:label ?countryLabel }
} GROUP BY ?creator ?creatorLabel ?countryLabel
ORDER BY DESC(?count)

Try it!

MaterialsEdit

SELECT ?materialLabel ?materialDescription (COUNT(?item) AS ?count) WHERE {
?item wdt:P31/wdt:P361? wd:Q164992.
?item wdt:P186 ?material
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?materialLabel ?materialDescription
ORDER BY DESC(?count) UCASE(?materialLabel)

Try it!

Image galleryEdit

#defaultView:ImageGrid
SELECT ?image ?item ?itemLabel ?collectionLabel WHERE {
?item wdt:P31/wdt:P361? wd:Q164992; wdt:P18 ?image; wdt:P195 ?collection.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Unreferenced statements about Oxford AstrolabesEdit

SELECT (SUBSTR(STR(?item),32) AS ?wdq) (SUBSTR(STR(?prop),32) AS ?wdp) ?object ?url WHERE {
?item wdt:P31/wdt:P361? wd:Q164992 ; wdt:P195 wd:Q6941088.
?item wdt:P973 ?url.
?item ?p ?statement.
  ?prop wikibase:claim ?p; wikibase:statementProperty ?ps  FILTER (?prop != wd:P973)
        FILTER (?prop != wd:P18).
  ?statement ?ps ?object .
  FILTER NOT EXISTS {?statement prov:wasDerivedFrom []}
} ORDER BY ?item

Try it!

Things called Astrolabe in English but with missing labels in other languagesEdit

SELECT (SUBSTR(STR(?q),32) AS ?wdq) (CONCAT("L",?astrolabe_lang) AS ?lang) ?astrolabe_label WHERE {
{SELECT ?astrolabe_lang ?astrolabe_label WHERE {
wd:Q164992 rdfs:label ?astrolabe_label. BIND(lang(?astrolabe_label) AS ?astrolabe_lang)
}
  }
?q rdfs:label "Astrolabe"@en.
    FILTER(NOT EXISTS {
   ?q rdfs:label ?label.
   FILTER(LANG(?label) = ?astrolabe_lang)
 })
}

Try it!

English Wikipedia articles about creators of astrolabes that are in the Museum of the History of ScienceEdit

SELECT DISTINCT ?person ?page ?image WHERE {
?item wdt:P31 wd:Q164992; wdt:P195 wd:Q6941088.
?item wdt:P170 ?person.
OPTIONAL { ?item wdt:P18 ?image }
?page schema:about ?person; schema:isPartOf <https://en.wikipedia.org/>
} ORDER BY ?page

Try it!

Descriptions of things in the History of Science MuseumEdit

SELECT ?item ?description (lang(?description) as ?lang) WHERE {
?item wdt:P195 wd:Q6941088.
?item schema:description ?description
}

Try it!

Astrolabes ordered by diameterEdit

#defaultView:BarChart
SELECT (str(?item) as ?name) ?diam WHERE {
?item wdt:P31 wd:Q164992; p:P2386/psv:P2386 ?valuenode. # astrolabes with a diameter property
?valuenode wikibase:quantityAmount ?length; wikibase:quantityUnit ?unit.
BIND(IF(?unit = wd:Q174728, ?length * 10,?length) as ?diam) # diameter in millimetres (unit is cm or mm)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?item rdfs:label ?itemLabel }
} ORDER BY DESC(?diam)

Try it!

Scatter-plot of diameter against year of creationEdit

#defaultView:ScatterChart
SELECT (YEAR(SAMPLE(?date)) as ?year) (SAMPLE(?diam) as ?diam1) (CONCAT(?itemLabel," ",SUBSTR(str(?item),32) ) as ?name) WHERE {
?item wdt:P31 wd:Q164992; wdt:P571 ?date; p:P2386/psv:P2386 ?valuenode. # astrolabes with a diameter property
?valuenode wikibase:quantityAmount ?length; wikibase:quantityUnit ?unit.
BIND(IF(?unit = wd:Q174728, ?length * 10,?length) as ?diam) # diameter in millimetres (unit is cm or mm)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?item rdfs:label ?itemLabel }
} group by ?item ?itemLabel

Try it!

Object with a given King numberEdit

SELECT * WHERE {
?item wdt:P31/wdt:P361?	wd:Q164992; wdt:P528 "150"
}

Try it!