Василиса▶ Я жду вашего обращения. Что Вы хотите узнать?
Логотип
Wikidata:SPARQL query service/queries/examples - Wikidata Wikidata:SPARQL query service/queries/examplesFrom Wikidata< Wikidata:SPARQL query service ‎ | queries Translate this page Other languages: Bahasa Indonesia  • ‎ Bahasa Melayu  • ‎ Deutsch  • ‎English • ‎ Esperanto  • ‎ Nederlands  • ‎ Türkçe  • ‎ català  • ‎ dansk  • ‎ español  • ‎ français  • ‎ italiano  • ‎ lietuvių  • ‎ polski  • ‎ português do Brasil  • ‎ română  • ‎ svenska  • ‎ čeština  • ‎ беларуская (тарашкевіца)‎  • ‎ русский  • ‎ українська  • ‎ עברית  • ‎ العربية  • ‎ �����  • ‎ 中文  • ‎ 日本語  • ‎ 한국어

This page is parsed by the web interface of the query service to fill the query example dialog. Many of the examples also work in template:Wikidata list template calls parsed by the Listerbot , which however requires the ?item field variable to be selected.

Consider adding a comment in the query noting what it illustrates, when and by whom it was written and which are its limitations given the current data and use of properties at Wikidata.

Some queries did not fit here because of technical restrictions:

Advanced examples which showcase more advanced functionality. Human examples which have all kinds of human related queries. Maintenance examples which help to curate all our items.ContentsSee also Wikibase RDF format Simple Queries

These basic queries help to understand SPARQL and the Wikibase RDF format .

CatsSELECT?item?itemLabelWHERE{?itemwdt:P31wd:Q146.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! GoatsSELECT?item?itemLabelWHERE{?itemwdt:P31wd:Q2934.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Horses (showing some info about them)#Illustrates optional fields, instances of subclasses, language fallback on label service, date to year conversion#Horses on WikidataSELECTDISTINCT?horse?horseLabel?mother?father(year(?birthdate)as?birthyear)(year(?deathdate)as?deathyear)?genderLabelWHERE{?horsewdt:P31/wdt:P279*wd:Q726.# Instance et sous-classes de Q726-ChevalOPTIONAL{?horsewdt:P25?mother.}# P25 : MèreOPTIONAL{?horsewdt:P22?father.}# P22 : PèreOPTIONAL{?horsewdt:P569?birthdate.}# P569 : Date de naissanceOPTIONAL{?horsewdt:P570?deathdate.}# P570 : Date de décèsOPTIONAL{?horsewdt:P21?gender.}# P21 : SexeSERVICEwikibase:label{#BabelRainbowbd:serviceParamwikibase:language"[AUTO_LANGUAGE],fr,ar,be,bg,bn,ca,cs,da,de,el,en,es,et,fa,fi,he,hi,hu,hy,id,it,ja,jv,ko,nb,nl,eo,pa,pl,pt,ro,ru,sh,sk,sr,sv,sw,te,th,tr,uk,yue,vec,vi,zh"}}ORDER BY?horse Try it! Cats, with pictures

The following query uses these:

Items: house cat (Q146)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , image (P18)    View with Reasonator   View with SQID

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

#defaultView:ImageGridSELECT?item?itemLabel?picWHERE{?itemwdt:P31wd:Q146.?itemwdt:P18?picSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Map of hospitals

The following query uses these:

Items: hospital (Q16917)    View with Reasonator   View with SQID Properties: 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

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

#added 2017-08#defaultView:MapSELECTdistinct*WHERE{?itemwdt:P31/wdt:P279*wd:Q16917;wdt:P625?geo.} Try it! Number of humans in Wikidata

Using the count function

SELECT(COUNT(?item)AS?count)WHERE{?itemwdt:P31wd:Q5.} Try it! Humans without children

In the simplest form:

The following query uses these:

Items: human (Q5)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , child (P40)    View with Reasonator   View with SQID #Demonstrates "no value" handlingSELECT?human?humanLabelWHERE{?humanwdt:P31wd:Q5.#find humans?humanrdf:typewdno:P40.#with at least one truthy P40 (child) statement defined to be "no value"SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it!

A similar query which also gives non-truthy "no value" statements:

SELECT?human?humanLabelWHERE{?humanwdt:P31wd:Q5.#find humans?humanp:P40?childStatement.#with at least one P40 (child) statement?childStatementrdf:typewdno:P40.#where the P40 (child) statement is defined to be "no value"SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Humans born in New York City

This example highlights the correct way to use the P19 property and by extension the P20 property. P19 is most specific known place of birth. So for example it is known that Donald Trump (Q22686) was born in Jamaica Hospital (Q23497866). Therefore he wouldn't show up in the first query.

Incorrect way:

selectdistinct?item?itemLabel?itemDescription?sitelinkswhere{?itemwdt:P31wd:Q5;# Any instance of a human.wdt:P19wd:Q60;# Who was born in New York City.# Note. Doesn't include humans with the birth place listed as a hospital# or an administrative area or other location of New York City.# Only humans listed as born in New York City. wikibase:sitelinks?sitelinks.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,nl"}}ORDER BYDESC(?sitelinks) Try it!

Correct way:

selectdistinct?item?itemLabel?itemDescription?sitelinkswhere{?itemwdt:P31wd:Q5;# Any instance of a human.wdt:P19/wdt:P131*wd:Q60;# Who was born in any value (eg. a hospital)# that has the property of 'administrative area of' New York City or New York City itself.wikibase:sitelinks?sitelinks.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,nl"}}ORDER BYDESC(?sitelinks) Try it! Items with a Wikispecies sitelink#illustrates sitelink selection, ";" notationSELECT?item?itemLabel?articleWHERE{?articleschema:about?item;schema:isPartOf<https://species.wikimedia.org/>.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}LIMIT200 . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } LIMIT 200<]<)+}"> Try it! Items about authors with a Wikispecies pageSELECT?author?authorLabel(COUNT(?paper)AS?count)WHERE{?articleschema:about?author;schema:isPartOf<https://species.wikimedia.org/>.?authorwdt:P31wd:Q5.?paperwdt:P50?author.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}GROUP BY?author?authorLabelORDER BYDESC(?count)LIMIT200 Try it! Recent Events

The following query uses these:

Items: occurrence (Q1190554)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , point in time (P585)    View with Reasonator   View with SQID , start time (P580)    View with Reasonator   View with SQID SELECT?event?eventLabel?dateWHERE{# find events?eventwdt:P31/wdt:P279*wd:Q1190554.# with a point in time or start dateOPTIONAL{?eventwdt:P585?date.}OPTIONAL{?eventwdt:P580?date.}# but at least one of thoseFILTER(BOUND(?date)&&DATATYPE(?date)=xsd:dateTime).# not in the future, and not more than 31 days agoBIND(NOW()-?dateAS?distance).FILTER(0<=?distance&&?distance<31).# and get a label as wellOPTIONAL{?eventrdfs:label?eventLabel.FILTER(LANG(?eventLabel)="en").}}# limit to 10 results so we don't timeoutLIMIT10 Try it! Popular eye colors among humans#illustrates bubblechart view, count#defaultView:BubbleChartSELECT?eyeColorLabel(COUNT(?human)AS?count)WHERE{?humanwdt:P31wd:Q5.?humanwdt:P1340?eyeColor.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}GROUP BY?eyeColorLabel Try it! Humans whose gender we know we don't know

The following query uses these:

Properties: sex or gender (P21)    View with Reasonator   View with SQID # Demonstrates filtering for "unknown value"SELECT?human?humanLabelWHERE{?humanwdt:P21?gender.FILTERwikibase:isSomeValue(?gender)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! URLs of Wikipedia in all languages

This query provides an alternative to scraping the Wikipedia.org portal page and various lists/tables of Wikipedias that are out there. (The sitematrix API is another alternative.)

SELECT?wikipediaWHERE{?wikipediawikibase:wikiGroup"wikipedia".} Try it! Names of Wikipedia articles in multiple languages

The query retrieves Wikipedia article names (in the main namespace) in various languages for the given Q identity.

SELECTDISTINCT?lang?nameWHERE{?articleschema:aboutwd:Q5;schema:inLanguage?lang;schema:name?name;schema:isPartOf[wikibase:wikiGroup"wikipedia"].FILTER(?langin('en','uz','ru','ko')).FILTER(!CONTAINS(?name,':')).} Try it! All items with a property# Sample to query all values of a property# Property talk pages on Wikidata include basic queries adapted to each propertySELECT?item?itemLabel?value?valueLabel# valueLabel is only useful for properties with item-datatypeWHERE{?itemwdt:P1800?value# change P1800 to another property SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}# remove or change limit for more resultsLIMIT10 Try it! Wikidata items of Wikipedia articles#Returns a list of Wikidata items for a given list of Wikipedia article names#List of Wikipedia article names (lemma) is like "WIKIPEDIA ARTICLE NAME"@LANGUAGE CODE with de for German, en for English, etc.#Language version and project is defined in schema:isPartOF with de.wikipedia.org for German Wikipedia, es.wikivoyage for Spanish Wikivoyage, etc.SELECT?lemma?itemWHERE{VALUES?lemma{"Wikipedia"@de"Wikidata"@de"Berlin"@de"Technische Universität Berlin"@de}?sitelinkschema:about?item;schema:isPartOf<https://de.wikipedia.org/>;schema:name?lemma.}; schema:name ?lemma. }<]<)+}"> Try it! Total population in the Øresund Region

The following query uses these:

Items: Øresund Region (Q297853)    View with Reasonator   View with SQID , metropolitan area (Q1907114)    View with Reasonator   View with SQID Properties: part of (P361)    View with Reasonator   View with SQID , population (P1082)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID , has part (P527)    View with Reasonator   View with SQID # by So9q, 2019-11-22# Total population in the Øresund Region# Example of the SUM aggregate functionSELECTdistinct?area?areaLabel(sum(?folkm_ngd)as?total_folkm)# the first two variables can be removed# if only the number is neededWHERE{?itemwdt:P361wd:Q297853.?itemwdt:P1082?folkm_ngd.?areawdt:P31wd:Q1907114.?areawdt:P527?item.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}group by?area?areaLabel Try it! Lexeme queriesAll forms in Swedish missing a pronunciation for the form with a representation identical to the lemma of the lexeme

The following query uses these:

Items: Swedish (Q9027)    View with Reasonator   View with SQID Properties: pronunciation audio (P443)    View with Reasonator   View with SQID # All forms in Swedish missing a pronunciation for the form with a representation identical to the lemma of the lexeme# So9q 13-01-2021SELECT?l?lemma?form?audioWHERE{?ldct:languagewd:Q9027;wikibase:lemma?lemma;ontolex:lexicalForm?form.?formontolex:representation?lemma.minus{?formwdt:P443?audio.}} Try it! Lexemes in English that match an expression

The following query uses these:

Items: English (Q1860)    View with Reasonator   View with SQID # Lexemes in English that match an expressionselect?lexemeId?lemmaWHERE{?lexemeIddct:languagewd:Q1860;wikibase:lemma?lemma.# only those lemmas that begin with "pota", i.e. "potato"FILTER(regex(?lemma,'^pota.*'))} Try it! Lexemes in Swedish with usage example that demonstrates both a form and a sense

The following query uses these:

Items: Swedish (Q9027)    View with Reasonator   View with SQID Properties: usage example (P5831)    View with Reasonator   View with SQID , demonstrates sense (P6072)    View with Reasonator   View with SQID , demonstrates form (P5830)    View with Reasonator   View with SQID #Lexemes in Swedish with usage example that demonstrates both a form and a sense# So9q 23-12-2020select?lexemeId?lemma?exampleWHERE{?lexemeId<http://purl.org/dc/terms/language>wd:Q9027;wikibase:lemma?lemma.?lexemeIdp:P5831?statement.?statementps:P5831?example;pq:P6072[];pq:P5830[].} Try it! Pictures of noun lexemes in English (picture dictionary à la Wikidata)

The following query uses these:

Items: English (Q1860)    View with Reasonator   View with SQID Properties: item for this sense (P5137)    View with Reasonator   View with SQID , image (P18)    View with Reasonator   View with SQID

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

# Lexemes in English with picture and description fetched from the concept Q-item# NB: when 2 or more pictures occur for the same lemma a preferred rank is missing on the Q-item. # Please fix that if you know how.# by So9q#defaultView:ImageGridselectdistinct?lexemeId?lemma?q_concept?q_conceptDescription?pictureWHERE{?lexemeIddct:languagewd:Q1860;wikibase:lemma?lemma;ontolex:sense?sense.?sensewdt:P5137?q_concept.?q_conceptwdt:P18?picture.# if you wish to only browse certain items you can insert a FILTER # regular expression here, like in the example above.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}order bylcase(?lemma)# order a-z Try it! German picture dictionary for young children

The following query uses these:

Items: German (Q188)    View with Reasonator   View with SQID , sovereign state (Q3624078)    View with Reasonator   View with SQID , rape (Q47092)    View with Reasonator   View with SQID , war (Q198)    View with Reasonator   View with SQID , violence (Q124490)    View with Reasonator   View with SQID , revolver (Q170382)    View with Reasonator   View with SQID , cigar (Q1576)    View with Reasonator   View with SQID , slang (Q8102)    View with Reasonator   View with SQID , pejorative (Q545779)    View with Reasonator   View with SQID , vulgarism (Q1521634)    View with Reasonator   View with SQID , profanity (Q184439)    View with Reasonator   View with SQID Properties: item for this sense (P5137)    View with Reasonator   View with SQID , image (P18)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID , language style (P6191)    View with Reasonator   View with SQID

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

# German picture dictionary for young children# NB: when 2 or more pictures occur for the same lemma a preferred rank is missing on the Q-item. # Please fix that if you know how.# If any inapproriate terms show up it is probably because the sense is missing a correct P5137# by So9q#defaultView:ImageGridselectdistinct?lexemeId?lemma?q_concept?q_conceptDescription?pictureWHERE{?lexemeIddct:languagewd:Q188;# change language herewikibase:lemma?lemma;ontolex:sense?sense.?sensewdt:P5137?q_concept.?q_conceptwdt:P18?picture.############# Exclusions############# Exclude out of scope conceptsMINUS{?q_conceptwdt:P31wd:Q3624078.}.# countries# Exclude non suitable conceptsVALUES?minus{wd:Q47092# rapewd:Q198# warwd:Q124490# violencewd:Q170382# revolverwd:Q1576#cigar#... add yours here}.MINUS{?sensewdt:P5137?minus.}.# Exclude senses not suitable for young children:VALUES?filter{wd:Q8102wd:Q545779wd:Q1521634wd:Q184439}.FILTERNOT EXISTS{?sensewdt:P6191?filter.}.# if you wish to only browse certain items you can insert a FILTER # regular expression here, like in the example above.SERVICEwikibase:label{bd:serviceParamwikibase:language"de,en".}}order bylcase(?lemma)# order a-z Try it! Lexeme languages by number of usage examples

The following query uses these:

Properties: usage example (P5831)    View with Reasonator   View with SQID , demonstrates sense (P6072)    View with Reasonator   View with SQID , demonstrates form (P5830)    View with Reasonator   View with SQID

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

# Lexeme languages by number of usage examples# by Vesihiisi# improved by So9q 23-20-2020 to only show those with both a form and a sense, # because that's what we really want #defaultView:BubbleChartSELECT?languageLabel(COUNT(?example)AS?count)WHERE{?laontolex:LexicalEntry;dct:language?language.?lp:P5831?statement.?statementps:P5831?example;pq:P6072[];pq:P5830[].SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}GROUP BY?languageLabelORDER BYDESC(?count) Try it! Lexemes describing a color

The following query uses these:

Items: color term (Q376431)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID # Lexemes describing a color# By VesihiisiSELECT?l?lemma?languageLabelWHERE{?laontolex:LexicalEntry;dct:language?language;wikibase:lemma?lemma.?lwdt:P31wd:Q376431.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?languageLabel Try it! Lexemes that means water ordered by language

The following query uses these:

Items: liquid water (Q29053744)    View with Reasonator   View with SQID Properties: item for this sense (P5137)    View with Reasonator   View with SQID # By So9q# Lexemes that means (liquid) waterselect?l?sense?lemma?languageLabelWHERE{?laontolex:LexicalEntry;# get from the special LexicalEntryontolex:sense?sense;# the sensedct:language?language;# the languagewikibase:lemma?lemma.# and the lemma?sensewdt:P5137wd:Q29053744.# change Q29053744 to anything you want SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}# Lower case before orderorder by(LCASE(?languageLabel)) Try it! The 100 most translated concepts in the Lexeme namespace# by So9q, 2019-11-21# no known limitations#defaultView:BubbleChartSELECT?meaning?meaningLabel(count(?l)as?count)WHERE{?laontolex:LexicalEntry;ontolex:sense?sense.# get the sense?sensewdt:P5137?meaning.#extract the meaningSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}group by?meaning?meaningLabel# 2 here to avoid "bad aggregate", see https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial#Painting_materialsorder bydesc(?count)# rank by the most translated concepts limit100# only show the 100 highest to avoid clutter Try it! Demonyms on map

The following query uses these:

Properties: ISO 639-1 code (P218)    View with Reasonator   View with SQID , demonym of (P6271)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

# Words describing people from a certain place# e.g. swede# by Vesihiisi#defaultView:MapSELECT?l?lemma?demoPlaceLabel?coordsWHERE{?laontolex:LexicalEntry;dct:language?language;wikibase:lemma?lemma.?languagewdt:P218'sv'.# language?lontolex:sense?sense.?sensewdt:P6271?demoPlace.?demoPlacewdt:P625?coordsSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Forms in Hebrew that are both feminine and masculine

The following query uses these:

Items: Hebrew (Q9288)    View with Reasonator   View with SQID , noun (Q1084)    View with Reasonator   View with SQID , masculine (Q499327)    View with Reasonator   View with SQID , feminine (Q1775415)    View with Reasonator   View with SQID # Forms of nouns in Hebrew that are both feminine and masculine# e.g. שמש# by Uziel302select?lexemeId?lemma?form?wordWHERE{?lexemeIddct:languagewd:Q9288;wikibase:lexicalCategorywd:Q1084;wikibase:lemma?lemma.?lexemeIdontolex:lexicalForm?form.?formwikibase:grammaticalFeaturewd:Q499327;wikibase:grammaticalFeaturewd:Q1775415;ontolex:representation?word.} Try it! Wikibase predicatesPropertiesProperties grouped by their parent property#Properties grouped by their parent property#TODO: should display links and numeric ids#defaultView:TreeSELECT?property2?property2Label?property1?property1LabelWHERE{?property1rdf:typewikibase:Property.#not replaceable with wikibase:Item, wikibase:Statement, wikibase:Reference at WDQS#https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#WDQS_data_differences?property1wdt:P1647?property2.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Subproperties of location (P276) #Subproperties of location (P276)SELECTDISTINCT?subProperties?subPropertiesLabelWHERE{?subPropertieswdt:P1647*wd:P276.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Properties grouped by their Wikibase datatype (Q19798645) with number of properties#Properties grouped by their type with number of propertiesSELECT(COUNT(?property)as?pcount)?wbtypeWHERE{?propertyrdf:typewikibase:Property.?propertywikibase:propertyType?wbtype.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}GROUP BY?wbtypeORDER BYDESC(?pcount) Try it! Properties with value a technical standard (Q317623) #Properties with value a technical standardSELECTDISTINCT?propertyRel?propertyItem?propertyItemLabelWHERE{?item?propertyRel?standard.?standardwdt:P31wd:Q317623.?propertyItemwikibase:directClaim?propertyRelSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! All properties with descriptions and aliases and typesSELECT?property?propertyType?propertyLabel?propertyDescription?propertyAltLabelWHERE{?propertywikibase:propertyType?propertyType.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYASC(xsd:integer(STRAFTER(STR(?property),'P'))) Try it! Properties connecting items of type zoo (Q43501) with items of type animal (Q729) select?p?pLabel(count(*)as?count){?s?pd?o.?pwikibase:directClaim?pd.?swdt:P31/wdt:P279*wd:Q729.?owdt:P31/wdt:P279*wd:Q43501.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}group by?p?pLabelorder bydesc(?count) Try it! Identifier properties present on one item, but absent on another#added November 1, 2020 (76 ids then)#TEMPLATE={ "template":"Identifiers present on the item for Penelope Cruz, but not on the item for Sean Connery"}SELECT?p?pLabel(SAMPLE(?url)as?url_comp2)WHERE{hint:Queryhint:optimizer"None".BIND(wd:Q4573as?comp1)BIND(wd:Q39666as?comp2){?comp2?wdt?v.?pwikibase:directClaim?wdt;wikibase:propertyTypewikibase:ExternalId.FILTERNOT EXISTS{?comp1?wdt[]}OPTIONAL{?pwdt:P1630?f}BIND(uri(REPLACE(?f,"\\$1",?v))as?url)}UNION{BIND(wd:Q4573as?p)}UNION{BIND(wd:Q39666as?p)}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}GROUP BY?p?pLabelORDER BY?url_comp2 Try it! ReferencesContent of a reference for a specific statement

The following query uses these:

Items: BEIC Digital Library (Q51955019)    View with Reasonator   View with SQID Properties: described by source (P1343)    View with Reasonator   View with SQID , section, verse, paragraph, or clause (P958)    View with Reasonator   View with SQID # See also the SPARQL manual# https://en.wikibooks.org/wiki/SPARQL/WIKIDATA_Qualifiers,_References_and_Ranks# In this example we look for statements which assign a specific value (Q51955019)# to the property P1343 and then look for references of that property, specifically# the string associated to P958 for the reference. May actually bring up references# for other P1343 statements; uses the shortened expression syntax with brackets.SELECT?item?referenceWHERE{?itemwdt:P1343wd:Q51955019.?itemp:P1343[prov:wasDerivedFrom[pr:P958?reference]].} Try it! Wikimedia projectsSitelinksSee also: Help:Sitelinks Countries that have sitelinks to en.wiki

The following query uses these:

Items: sovereign state (Q3624078)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID SELECT?country?countryLabel?articleWHERE{?countrywdt:P31wd:Q3624078.# sovereign state?articleschema:about?country.?articleschema:isPartOf<https://en.wikipedia.org/>.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Canadian subjects with no English article in Wikipedia#added before 2019-02SELECT?item?itemLabel?cntWHERE{{SELECT?item(COUNT(?sitelink)AS?cnt)WHERE{?itemwdt:P27|wdt:P205|wdt:P17wd:Q16.#Canadian subjects.minus{?itemwdt:P106wd:Q488111.}#Minus occupations that would be inappropriate in most situations.minus{?itemwdt:P106wd:Q3286043.}minus{?itemwdt:P106wd:Q4610556.}?sitelinkschema:about?item.FILTERNOT EXISTS{?articleschema:about?item.?articleschema:isPartOf<https://en.wikipedia.org/>.#Targeting Wikipedia language where subjects has no article.}}GROUP BY?itemORDER BYDESC(?cnt)LIMIT1000#Sorted by amount of articles in other languages. Result limited to 1000 lines to not have a timeout error.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,fr,es,de"}#Service to resolve labels in (fallback) languages: automatic user language, English, French, Spanish, German.}ORDER BYDESC(?cnt) Try it! Countries that have a Featured Article on Russian WikipediaSELECT?sitelink?itemLabelWHERE{?itemwdt:P31wd:Q6256.?sitelinkschema:isPartOf<https://ru.wikipedia.org/>;schema:about?item;wikibase:badgewd:Q17437796.# Sitelink is badged as a Featured ArticleSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}.}ORDER BY?itemLabel Try it! Numbers of Wikipedia sitelinks for items with Art UK artist ID (P1367) for each languageSELECT?lang(COUNT(DISTINCT?article)AS?count)WHERE{hint:Queryhint:optimizer"None".?itemwdt:P1367?yp_id.?articleschema:about?item.# find articles about things with a BBC 'Your paintings' artist identifier?articleschema:isPartOf/wikibase:wikiGroup"wikipedia".# only Wikipedias articleshint:Priorhint:gearing"forward".# This hint says to search the property chain above from left to right ("forward"),# i.e. it is checked if each previously found value for ?article is linked to a Wikipedia.# The default ("reverse") would be to search it from right to left, i.e. find all Wikipedia# articles first, and then select the intersection with the previously found values of ?article.?articleschema:inLanguage?lang.}GROUP BY?langORDER BYDESC(?count) Try it! Titles of articles about Ukrainian villages on Romanian Wikipedia#Show titles of articles about Ukrainian villages on Romanian Wikipedia, plus English and Ukrainian labels in Wikidata items#added in 2017-05SELECTDISTINCT?item?LabelEN?LabelUK?page_titleROWHERE{?itemwdt:P31wd:Q532.?itemwdt:P17wd:Q212.?articleschema:about?item;schema:isPartOf<https://ro.wikipedia.org/>;schema:name?page_titleRO.?itemrdfs:label?LabelENfilter(lang(?LabelEN)="en").?itemrdfs:label?LabelUKfilter(lang(?LabelUK)="uk").}LIMIT300 Try it! Wikisource pages for authors of scientific articles#Wikisource pages for authors of scientific articles, ordered by Wikisource language#added in 2017-09SELECTDISTINCT?item?wikisourceSitelink?wikisourceLanguageWHERE{?wikisourceSitelinkschema:isPartOf[wikibase:wikiGroup"wikisource"];schema:inLanguage?wikisourceLanguage;schema:about?item.?paperwdt:P31wd:Q13442814;wdt:P50?item.}ORDER BY?wikisourceLanguageLIMIT300 Try it! Items with a GTAA id and their articles on the Dutch and English Wikipediaselect?item?itemLabel?gtaa?_articleEN?_articleNLwhere{?itemwdt:P1741?gtaa.# GTAA idOPTIONAL{?_articleENschema:about?item.?_articleNLschema:about?item.?_articleENschema:isPartOf<https://en.wikipedia.org/>.?_articleNLschema:isPartOf<https://nl.wikipedia.org/>.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,nl".}} Try it! People deceased in 2018 ordered by the number of sitelinksselect?person?personLabel?died?sitelinkswhere{?personwdt:P31wd:Q5;wdt:P570?died.filter(?died>="2018-01-01T00:00:00Z"^^xsd:dateTime&&?died<"2019-01-01T00:00:00Z"^^xsd:dateTime)?personwikibase:sitelinks?sitelinks.servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}order bydesc(?sitelinks)limit100 Try it! List of small monuments with link to Commons category (either from sitelink and P373)SELECT?item?comm?p373?catWHERE{?itemwdt:P131*wd:Q894107.# ... municipality ...optional{?commschema:about?item;schema:isPartOf<https://commons.wikimedia.org/>.}BIND(replace(wikibase:decodeUri(SUBSTR(STR(?comm),45)),"_"," ")AS?comm_decode)optional{?itemwdt:P373?p373.}bind(COALESCE(?comm_decode,?p373)as?cat).VALUES?trida{wd:Q1746392wd:Q108325wd:Q4989906wd:Q10861631wd:Q15077340wd:Q1516537wd:Q47008262}# chapel, small monument, memorial, belltower, memorial monument, technical monument, group of small monuments ?itemwdt:P31/wdt:P279*?trida.# small monument} Try it! EntertainmentRock bands that start with "M"SELECTDISTINCT?band?bandLabelWHERE{?bandwdt:P31wd:Q5741069.?bandrdfs:label?bandLabel.FILTER(STRSTARTS(?bandLabel,'M')).} Try it! Winner of the Academy Awards by Award and TimeSELECTDISTINCT?item?itemLabel?awardLabel?time{?itemwdt:P106/wdt:P279*wd:Q3455803;# Items with the Occupation(P106) of Director(Q3455803) or a subclass(P279)p:P166?awardStat.# ... with an awarded(P166) statement?awardStatpq:P805?award;# Get the award (which is "subject of" XXth Academy Awards)ps:P166wd:Q103360.# ... that has the value Academy Award for Best Director(Q103360)?awardwdt:P585?time.# the "point of time" of the Academy AwardSERVICEwikibase:label{# ... include the labelsbd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BYDESC(?time) Try it! Academy award dataitems used: Academy Awards (Q19020) human (Q5) Properties used: instance of (P31) award received (P166) statement is subject of (P805) for work (P1686) point in time (P585) director (P57) SELECT?human?humanLabel?awardEditionLabel?awardLabel?awardWork?awardWorkLabel?director?directorLabel?timeWHERE{{SELECT(SAMPLE(?human)AS?human)?award?awardWork(SAMPLE(?director)AS?director)(SAMPLE(?awardEdition)AS?awardEdition)(SAMPLE(?time)AS?time)WHERE{?awardwdt:P31wd:Q19020.# All items that are instance of(P31) of Academy awards (Q19020){?humanp:P166?awardStat.# Humans with an awarded(P166) statement?awardStatps:P166?award.# ... that has any of the values of ?award?awardStatpq:P805?awardEdition.# Get the award edition (which is "subject of" XXth Academy Awards)?awardStatpq:P1686?awardWork.# The work they have been awarded for?humanwdt:P31wd:Q5.# Humans}UNION{?awardWorkwdt:P31wd:Q11424.# Films?awardWorkp:P166?awardStat.# ... with an awarded(P166) statement?awardStatps:P166?award.# ... that has any of the values of ?award?awardStatpq:P805?awardEdition.# Get the award edition (which is "subject of" XXth Academy Awards)}OPTIONAL{?awardEditionwdt:P585?time.# the "point of time" of the Academy Award?awardWorkwdt:P57?director.}}GROUP BY?awardWork?award# We only want every movie once for a category (a 'random' person is selected)}SERVICEwikibase:label{# ... include the labelsbd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYDESC(?time) Try it! People that received both Academy Award and Nobel Prize

The following query uses these:

Items: Nobel Prize (Q7191)    View with Reasonator   View with SQID , Academy Awards (Q19020)    View with Reasonator   View with SQID Properties: award received (P166)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID SELECTDISTINCT?person?personLabelWHERE{?personwdt:P166/wdt:P31?wd:Q7191.?personwdt:P166/wdt:P31?wd:Q19020.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Number of handed out academy awards per award typeItems used: Academy Awards (Q19020) , human (Q5) Properties used: instance of (P31) , award received (P166) , statement is subject of (P805) , for work (P1686) , point in time (P585) director (P57) SELECT?awardCount?award?awardLabelWHERE{{SELECT(COUNT(?award)AS?awardCount)?awardWHERE{{SELECT(SAMPLE(?human)AS?human)?award?awardWork(SAMPLE(?director)AS?director)(SAMPLE(?awardEdition)AS?awardEdition)(SAMPLE(?time)AS?time)WHERE{?awardwdt:P31wd:Q19020.# All items that are instance of(P31) of Academy awards (Q19020){?humanp:P166?awardStat.# Humans with an awarded(P166) statement?awardStatps:P166?award.# ... that has any of the values of ?award?awardStatpq:P805?awardEdition.# Get the award edition (which is "subject of" XXth Academy Awards)?awardStatpq:P1686?awardWork.# The work they have been awarded for?humanwdt:P31wd:Q5.# Humans}UNION{?awardWorkwdt:P31wd:Q11424.# Films?awardWorkp:P166?awardStat.# ... with an awarded(P166) statement?awardStatps:P166?award.# ... that has any of the values of ?award?awardStatpq:P805?awardEdition.# Get the award edition (which is "subject of" XXth Academy Awards)}OPTIONAL{?awardEditionwdt:P585?time.# the "point of time" of the Academy Award?awardWorkwdt:P57?director.}}GROUP BY?awardWork?award# We only want every movie once for a category (a 'random' person is selected)}}GROUP BY?awardORDER BYASC(?awardCount)}SERVICEwikibase:label{# ... include the labelsbd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Film directors ranked by number of sitelinks multiplied by their number of filmsSELECT?director?director_label?films?sitelinks((?films*?sitelinks)as?rank)WHERE{{SELECT?director(count(distinct?film)as?films)(count(distinct?sitelink)as?sitelinks)WHERE{?directorwdt:P106wd:Q2526255.# has "film director" as occupation?filmwdt:P57?director.# get all films directed by the director?sitelinkschema:about?director.# get all the sitelinks about the director}GROUP BY?director}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".# Get label if it exists?directorrdfs:label?director_label}}ORDER BYDESC(?rank)LIMIT100 Try it! The Simpsons television series episodes list by seasonItems used: The Simpsons (Q886) Properties used: part of (P361) , series ordinal (P1545) SELECT?show?showLabel?seasonNumber?episode?episodeLabelWHERE{BIND(wd:Q886as?show).?seasonwdt:P361?show.?episodewdt:P361?season.?seasonp:P179[pq:P1545?seasonNumber].SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BYxsd:integer(?seasonNumber) Try it! Pokémon!Items used: Pokémon species (Q3966183) Properties used: instance of (P31) subclass of (P279) Pokédex / Pokémon browser number (P1685) # Updated 2020-06-17# Gotta catch 'em allSELECTDISTINCT?pokemon?pokemonLabel?pokedexNumberWHERE{?pokemonwdt:P31/wdt:P279*wd:Q3966183.?pokemonp:P1685?statement.?statementps:P1685?pokedexNumber;pq:P972wd:Q20005020.FILTER(!wikibase:isSomeValue(?pokedexNumber))SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BY(?pokedexNumber) Try it! Law & Order episodesItems used: episode (Q1983062) Law & Order (Q321423) Properties used: part of the series (P179) instance of (P31) series ordinal (P1545) title (P1476) publication date (P577) # All Law & Order episodes on Wikidata.# According to enwp, “[a] total of 456 original episodes… aired before cancellation” (https://en.wikipedia.org/wiki/List_of_Law_&_Order_episodes).# As of this writing, the query returns 451 results, so some episodes are missing (either without item or lacking the necessary statements to match this query).SELECT(SAMPLE(?seasonNumber)AS?seasonNumber)(SAMPLE(?episodeNumber)AS?episodeNumber)(SAMPLE(?title)AS?title)(MIN(?pubDate)AS?pubDate)?episode{# All episodes should be instance of episode with series Law & Order.?episodewdt:P31wd:Q21191270;wdt:P179wd:Q321423.# Many of them also have the season as series, so we can get episode and season number from qualifiers there.OPTIONAL{?episodep:P179[# the season also has series Law & Orderps:P179/p:P179[ps:P179wd:Q321423;pq:P1545?seasonNumber];pq:P1545?episodeNumber]}OPTIONAL{?episodewdt:P1476?title.}OPTIONAL{?episodewdt:P577?pubDate.}}GROUP BY?episode# make sure we return each episode only once – a few have multiple publication dates, for exampleORDER BYIF(BOUND(?seasonNumber),xsd:integer(?seasonNumber),1000)xsd:integer(?episodeNumber)?title Try it! Main subjects of West Wing episodesSELECTDISTINCT?episode?ordinal?episodeLabel?subject?subjectLabelWHERE{?episodewdt:P31/wdt:P279*wd:Q1983062;p:P179?statement.OPTIONAL{?episodewdt:P921?subject}?statementps:P179wd:Q3577037;pq:P1545?ordinalSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYxsd:integer(?ordinal) Try it! Movies with Bud SpencerSELECT?item?itemLabel(MIN(?date)AS?firstReleased)?_imageWHERE{?itemwdt:P161wd:Q221074;wdt:P577?dateSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}OPTIONAL{?itemwdt:P18?_image.}}GROUP BY?item?itemLabel?_imageORDER BY(?date) Try it! Fictional subjects of the Marvel UniverseSELECT?char?charName(GROUP_CONCAT(DISTINCT?typeLabel;separator=", ")AS?types)(GROUP_CONCAT(DISTINCT?universeLabel;separator=", ")AS?universes)WHERE{?charwdt:P1080wd:Q931597;wdt:P31?type;wdt:P1080?universe.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?charrdfs:label?charName.?universerdfs:label?universeLabel.?typerdfs:label?typeLabel.}}GROUP BY?char?charName Try it! Contemporary Indian actressesSELECT?item?itemLabel?itemDescription(SAMPLE(?img)AS?image)(SAMPLE(?dob)AS?dob)?slWHERE{?itemwdt:P106wd:Q33999;wdt:P27wd:Q668;wdt:P21wd:Q6581072.MINUS{?itemwdt:P570[]}OPTIONAL{?itemwdt:P18?img}OPTIONAL{?itemwdt:P569?dob}OPTIONAL{?itemwikibase:sitelinks?sl}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}GROUP BY?item?itemLabel?itemDescription?slORDER BYDESC(?sl) Try it! Articles on Punjabi (Gurmukhi) Wikipedia about Pakistani actresses#added 2017-03-25 (46 results)SELECT?sitelinkWHERE{# gender = female?itemwdt:P21wd:Q6581072.# country = Pakistan (Q25){?itemwdt:P27wd:Q843}# occupation = actress (Q33999){?itemwdt:P106wd:Q33999}# look for articles (sitelinks) in Punjabi ("pa"){?sitelinkschema:about?item.?sitelinkschema:inLanguage"pa"}# humans only?itemwdt:P31wd:Q5.}#Listeria can only handle up to 5000LIMIT5000 Try it! All Dr. Who performers

The following query uses these:

Items: regeneration of The Doctor (Q47543030)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , series ordinal (P1545)    View with Reasonator   View with SQID , performer (P175)    View with Reasonator   View with SQID #added 2017-07-16, updated 2020-07-08SELECT?doctor?doctorLabel?ordinal?performer?performerLabelWHERE{?doctorwdt:P31wd:Q47543030.OPTIONAL{?doctorwdt:P1545?ordinal}OPTIONAL{?doctorp:P175/ps:P175?performer}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BYASC(xsd:integer(?ordinal)) Try it! Movies and their narrative location on a map

The following query uses these:

Items: film (Q11424)    View with Reasonator   View with SQID Properties: narrative location (P840)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

#defaultView:MapSELECT?movie?movieLabel?narrative_location?narrative_locationLabel?coordinatesWHERE{?moviewdt:P840?narrative_location;wdt:P31wd:Q11424.?narrative_locationwdt:P625?coordinates.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Movies released in 2017

The following query uses these:

Items: film (Q11424)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , publication date (P577)    View with Reasonator   View with SQID SELECTDISTINCT?item?itemLabelWHERE{?itemwdt:P31wd:Q11424.?itemwdt:P577?pubdate.FILTER((?pubdate>="2017-01-01T00:00:00Z"^^xsd:dateTime)&&(?pubdate<="2017-12-31T00:00:00Z"^^xsd:dateTime))SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Musicians or singers that have a genre containing 'rock'items used: singer (Q177220) human (Q5) musician (Q639669) Properties used: instance of (P31) occupation (P106) genre (P136) SELECTDISTINCT?human?humanLabelWHERE{VALUES?professions{wd:Q177220wd:Q639669}?humanwdt:P31wd:Q5.?humanwdt:P106?professions.?humanwdt:P136?genre.?humanwikibase:statements?statementcount.?genrerdfs:label?genreLabel.FILTERCONTAINS(?genreLabel,"rock").FILTER(?statementcount>50).SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?humanLabelLIMIT50 50 ) . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?humanLabel LIMIT 50<]<)+}"> Try it! Fictional characters whose birth/death date is in the current decade

The following query uses these:

Items: fictional character (Q95074)    View with Reasonator   View with SQID Properties: subclass of (P279)    View with Reasonator   View with SQID , instance of (P31)    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 SELECTDISTINCT?character?characterLabel?birth?deathWITH{# Fictional character subclasses as a named subquerySELECT?fictiontypeWHERE{?fictiontypewdt:P279*wd:Q95074.hint:Priorhint:gearing"forward".}}AS%iWHERE{INCLUDE%i?characterwdt:P31?fictiontype.# Date of birth{?characterwdt:P569?birth.}# Date of deathUNION{?characterwdt:P570?death.}# Get actual decade to compare with datesBIND(xsd:integer(YEAR(NOW())/10)as?actual_decade).# Only show characters born or deceased in the current decadeFILTER(xsd:integer(YEAR(?birth)/10)=?actual_decade||xsd:integer(YEAR(?death)/10)=?actual_decade)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?birth?death Try it! GeographyContinentsContinentsSELECT?continent?continentLabelWHERE{?continentwdt:P31wd:Q5107.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYxsd:integer(SUBSTR(STR(?continent),STRLEN("http://www.wikidata.org/entity/Q")+1)) Try it! Some other continents continent (P30) SELECT?continentLabelWHERE{{# subquery for optimization so the label service doesn’t have to do as much work (228?ms vs 20731?ms)SELECTDISTINCT?continentWHERE{[]wdt:P30?continent.}}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYxsd:integer(SUBSTR(STR(?continent),STRLEN("http://www.wikidata.org/entity/Q")+1)) Try it! Places with continent Antarctica more than 3000?km north of south poleItems Used: South Pole (Q933) Antarctica (Q51) Properties Used: coordinate location (P625) continent (P30) #defaultView:MapSELECT?place?placeLabel?locationWHERE{wd:Q933wdt:P625?southPole.# coordinates of south pole?placewdt:P30wd:Q51;# continent: antarcticawdt:P625?location.FILTER(geof:distance(?location,?southPole)>3000).# over 3000?km away from south poleSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! CountriesList of present-day countries and capital(s)SELECTDISTINCT?country?countryLabel?capital?capitalLabelWHERE{?countrywdt:P31wd:Q3624078.#not a former countryFILTERNOT EXISTS{?countrywdt:P31wd:Q3024240}#and no an ancient civilisation (needed to exclude ancient Egypt)FILTERNOT EXISTS{?countrywdt:P31wd:Q28171280}OPTIONAL{?countrywdt:P36?capital}.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?countryLabel Try it! UN member statesSELECTDISTINCT?stateWHERE{?statewdt:P31/wdt:P279*wd:Q3624078;p:P463?memberOfStatement.?memberOfStatementawikibase:BestRank;ps:P463wd:Q1065.MINUS{?memberOfStatementpq:P582?endTime.}MINUS{?statewdt:P576|wdt:P582?end.}} Try it! Largest cities per countryItems used: city (Q515) Properties used: instance of (P31) subclass of (P279) population (P1082) coordinate location (P625) country (P17) #Largest cities per countrySELECTDISTINCT?city?cityLabel?population?country?countryLabel?locWHERE{{SELECT(MAX(?population)AS?population)?countryWHERE{?citywdt:P31/wdt:P279*wd:Q515.?citywdt:P1082?population.?citywdt:P17?country.}GROUP BY?countryORDER BYDESC(?population)}?citywdt:P31/wdt:P279*wd:Q515.?citywdt:P1082?population.?citywdt:P17?country.?citywdt:P625?loc.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Wikidata people per million inhabitants for all EU countries#Interesting maintenance query that shows the relative prominence of a country's current (living) population on Wikidata. The query tends to time out when using all countries at once, but it might be possible to get the figures for each individual country by using uncommenting the line as indicated belowSELECT?country?countryLabel?wikiPersons?population(ROUND(?wikiPersons/?population*1000000)AS?wikiPersonsPerM)WHERE{{SELECT?country(count(*)as?wikiPersons)WHERE{{SELECTDISTINCT?person?countryWHERE{wd:Q458wdt:P150?country.# European Union contains administrative territorial entity# BIND( wd:Q30 AS ?country ) # use instead of previous line to check individual countries?personwdt:P31wd:Q5.?personwdt:P27?country.FILTERNOT EXISTS{?personwdt:P570?date}# only count living people}}}GROUP BY?country}?countrywdt:P1082?populationSERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BYDESC(?wikiPersonsPerM) Try it! Papers about wikidataItems used: article (Q191067) Wikidata (Q2013) Properties used: instance of (P31) subclass of (P279) main subject (P921) #papers about WikidataSELECT?item?itemLabelWHERE{?item(wdt:P31/wdt:P279*)wd:Q191067.?itemwdt:P921wd:Q2013.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}LIMIT100 Try it! Countries sorted by populationItems used: country (Q6256) Properties used: instance of (P31) population (P1082) # defaultView:BubbleChartSELECTDISTINCT?countryLabel?population{?countrywdt:P31wd:Q6256;wdt:P1082?population.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?population?countryLabelORDER BYDESC(?population) Try it! Country populations together with total city populations

Lists for each country the population and the total of the populations of all cities of this country. If data were complete and populations were measured at the same time for each country and the respective cities then the ratio would be 1.

SELECT?country?countryLabel?population?totalCityPopulation(?population/?totalCityPopulationAS?ratio){?countrywdt:P1082?population.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}{SELECT?country(SUM(?cityPopulation)AS?totalCityPopulation)WHERE{?citywdt:P31wd:Q515.?citywdt:P17?country.?citywdt:P1082?cityPopulation.}GROUP BY?country}}ORDER BY?ratio Try it! Names of African countries in all their official languages and English

The following query uses these:

Items: Africa (Q15)    View with Reasonator   View with SQID , country (Q6256)    View with Reasonator   View with SQID Properties: continent (P30)    View with Reasonator   View with SQID , official language (P37)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID , Wikimedia language code (P424)    View with Reasonator   View with SQID SELECTDISTINCT?item?itemLabel_ol?official_language?itemLabel_enWHERE{?itemwdt:P30wd:Q15;wdt:P37?officiallanguage;wdt:P31wd:Q6256.?officiallanguagewdt:P424?langcode.?itemrdfs:label?itemLabel_ol.FILTER(lang(?itemLabel_ol)=?langcode)?itemrdfs:label?itemLabel_en.FILTER(lang(?itemLabel_en)='en')?officiallanguagerdfs:label?official_language.FILTER(lang(?official_language)='en')}ORDER BY?item?itemLabel_lol?official_language Try it! Languages and dialects spoken in the Netherlands with their optional Wikipedia editionsselectdistinct?language?languageLabel?wikipediaLabelwhere{?languagewdt:P31?instance;wdt:P17wd:Q55.filter(?instancein(wd:Q34770,wd:Q33384)).optional{?wikipediawdt:P31wd:Q10876391;wdt:P407?language.}SERVICEwikibase:label{bd:serviceParamwikibase:language"nl,en".}}group by?language?languageLabel?wikipediaLabel Try it! CitiesPopulation of cities and towns in Denmark and their OSM relation id# Population of cities and towns in Denmark and their OSM relation id# This shows a simple OR using VALUES and a variableSELECT?city?cityLabel?population?OSM_relation_IDWHERE{SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}VALUES?town_or_city{wd:Q3957wd:Q515}?city(wdt:P31/(wdt:P279*))?town_or_city;wdt:P17wd:Q35.OPTIONAL{?citywdt:P1082?population.}OPTIONAL{?citywdt:P402?OSM_relation_ID.}}LIMIT100 Try it! Former capitalsProperties used: capital (P36) coordinate location (P625) end time (P582) dissolved, abolished or demolished date (P576) #defaultView:MapSELECTDISTINCT?country?countryLabel?capital?capitalLabel?coordinates?endedWHERE{?countryp:P36?stat.?statps:P36?capital.?capitalwdt:P625?coordinates.OPTIONAL{?countrywdt:P582|wdt:P576?ended.}OPTIONAL{?capitalwdt:P582|wdt:P576?ended.}OPTIONAL{?statpq:P582?ended.}FILTER(BOUND(?ended)).SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Largest cities of the world#defaultView:BubbleChartSELECTDISTINCT?cityLabel?population?gpsWHERE{?citywdt:P31/wdt:P279*wd:Q515.?citywdt:P1082?population.?citywdt:P625?gps.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?population)LIMIT100 Try it! Cities as big as Eindhoven give or take 1000#defaultView:MapSELECTDISTINCT?city?cityLabel?location?populatie2WHERE{wd:Q9832wdt:P1082?populatie.?citywdt:P1082?populatie2;wdt:P625?location.FILTER(abs(?populatie-?populatie2)<1000)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl"}} Try it! Where in the world is Antwerp

The following query uses these:

Items: human settlement (Q486972)    View with Reasonator   View with SQID Properties: subclass of (P279)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

#defaultView:MapSELECTDISTINCT?settlement?name?coorWHERE{?subclass_settlementwdt:P279+wd:Q486972.?settlementwdt:P31?subclass_settlement;wdt:P625?coor;rdfs:label?name.FILTERregex(?name,"Antwerp","i")} Try it! Destinations from Antwerp International airport

The following query uses these:

Items: Antwerp International Airport (Q17480)    View with Reasonator   View with SQID Properties: connecting line (P81)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID , place served by transport hub (P931)    View with Reasonator   View with SQID

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

#defaultView:MapSELECT?connectsairport?connectsairportLabel?place_served?place_servedLabel?coorWHERE{VALUES?airport{wd:Q17480}# Antwerp international airport wd:Q17480?airportwdt:P81?connectsairport;wdt:P625?base_airport_coor.?connectsairportwdt:P931?place_served;wdt:P625?coor.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Cities connected by the European route E40

The following query uses these:

Items: European route E40 (Q327162)    View with Reasonator   View with SQID Properties: connects with (P2789)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

#defaultView:MapSELECT?city?cityLabel?coordinatesWHERE{VALUES?highway{wd:Q327162}?highwaywdt:P2789?city.?citywdt:P625?coordinates.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Cities connected by the Trans-Mongolian and Trans-Siberian Railway

The following query uses these:

Items: Trans-Mongolian Railway (Q559037)    View with Reasonator   View with SQID , Trans-Siberian railway (Q58767)    View with Reasonator   View with SQID Properties: connects with (P2789)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

#defaultView:MapSELECT?city?cityLabel?coordinatesWHERE{VALUES?highway{wd:Q559037wd:Q58767}?highwaywdt:P2789?city.?citywdt:P625?coordinates.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Cities connected to Paramaribo (Suriname) by main roads

The following query uses these:

Items: Paramaribo (Q3001)    View with Reasonator   View with SQID Properties: connects with (P2789)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

#defaultView:MapSELECTDISTINCT?connection?connectionLabel?connectedWith?connectedWithLabel?coorWHERE{VALUES?city{wd:Q3001}# wd:Q3001 = Paramaribo}?connectionwdt:P2789+?city;wdt:P2789+?connectedWith.?connectedWithwdt:P625?coor.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Names of 100 cities with a population larger than 1000000 in the native languages of their countries

The following query uses these:

Items: city (Q515)    View with Reasonator   View with SQID Properties: population (P1082)    View with Reasonator   View with SQID , instance of (P31)    View with Reasonator   View with SQID , country (P17)    View with Reasonator   View with SQID , official language (P37)    View with Reasonator   View with SQID , Wikimedia language code (P424)    View with Reasonator   View with SQID # Show the names of 100 cities with a population larger than 1000000 in the native languages of their countriesSELECT?city?cityLabel?country?countryLabel?lang?langLabel?langCode?populationWHERE{?citywdt:P1082?population.FILTER(?population>1000000)?citywdt:P31wd:Q515;wdt:P17?country;rdfs:label?cityLabel.?countrywdt:P37?lang;rdfs:label?countryLabel.?langwdt:P424?langCode;rdfs:label?langLabel.FILTER(lang(?cityLabel)=?langCode)FILTER(lang(?countryLabel)=?langCode)FILTER(lang(?langLabel)=?langCode)}LIMIT100 Try it! Distances between any two cities or municipalities in an areagrouped by dist range, color-coded

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:BarChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from?to?distGrpWHERE{{SELECT?from?to?distNum?mun?mun2WHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}BIND(geof:distance(?loc,?loc2)AS?distNum).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}}FILTER(CONCAT(?from,STR(?mun))<=CONCAT(?to,STR(?mun2))).#BIND(IF(STR(?from) < STR(?to),CONCAT(?from," <--> ",?to),# CONCAT(?to," <--> ",?from)) AS ?distLabel).BIND(COALESCE(IF(?distNum>=40,"40 - .. km",1/0),IF(?distNum>=30,"30 - 40 km",1/0),IF(?distNum>=20,"20 - 30 km",1/0),IF(?distNum>=10,"10 - 20 km",1/0),IF(?distNum>=5,"05 - 10 km",1/0),IF(?distNum>=1,"01 - 05 km","00 - 01 km"))AS?distGrp).}ORDER BY?from?distGrp ",?to), # CONCAT(?to," <--> ",?from)) AS ?distLabel). BIND(COALESCE( IF(?distNum >= 40, "40 - .. km", 1/0), IF(?distNum >= 30, "30 - 40 km", 1/0), IF(?distNum >= 20, "20 - 30 km", 1/0), IF(?distNum >= 10, "10 - 20 km", 1/0), IF(?distNum >= 5, "05 - 10 km", 1/0), IF(?distNum >= 1, "01 - 05 km", "00 - 01 km")) AS ?distGrp). } ORDER BY ?from ?distGrp<]<)+}"> Try it! grouped per municipality on x-axis, alphabetically

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:ScatterChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from(?distGrp1AS?kilometers)?toWHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}BIND(geof:distance(?loc,?loc2)AS?distNum).BIND(STR(ROUND(?distNum))AS?distGrp0).BIND(CONCAT(SUBSTR("000",STRLEN(?distGrp0)+1),?distGrp0,".",STR(ROUND((?distNum-FLOOR(?distNum))*10))," km")AS?distGrp1).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}ORDER BY?from?kilometers Try it! grouped per municipality on x-axis, by sum of dist

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:ScatterChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from(?distNumAS?kilometers)?toWHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}BIND(geof:distance(?loc,?loc2)AS?distNum).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}ORDER BY?from?kilometers Try it! grouped per municipality on x-axis, animated per municipality on x-axis

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:ScatterChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from(?distNumAS?kilometers)?to(?fromAS?animation)WHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}BIND(geof:distance(?loc,?loc2)AS?distNum).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}ORDER BY?from?kilometers Try it! grouped per municipality on x-axis, animated per municipality on z-axis

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:ScatterChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from(?distNumAS?kilometers)?to(?toAS?animation)WHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}BIND(geof:distance(?loc,?loc2)AS?distNum).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}ORDER BY?from?kilometers Try it! grouped per municipality on x-axis, animated by fixed dist range groups

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:ScatterChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from(?distNumAS?kilometers)?to(?distGrpAS?animation)WHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}#FILTER (STR(?mun) <= STR(?mun2)).BIND(geof:distance(?loc,?loc2)AS?distNum).BIND(COALESCE(IF(?distNum>=40,"40 km und mehr",1/0),IF(?distNum>=30,"30 - 40 km",1/0),IF(?distNum>=20,"20 - 30 km",1/0),IF(?distNum>=10,"10 - 20 km",1/0),IF(?distNum>=5,"05 - 10 km",1/0),IF(?distNum>=1,"01 - 05 km","00 - 01 km"))AS?distGrp).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}ORDER BY?animation?from?kilometers= 30, "30 - 40 km", 1/0), IF(?distNum >= 20, "20 - 30 km", 1/0), IF(?distNum >= 10, "10 - 20 km", 1/0), IF(?distNum >= 5, "05 - 10 km", 1/0), IF(?distNum >= 1, "01 - 05 km", "00 - 01 km")) AS ?distGrp). SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?mun rdfs:label ?from. ?mun2 rdfs:label ?to. } } ORDER BY ?animation ?from ?kilometers<]<)+}"> Try it! grouped per municipality on x-axis, animated by ranked dist (farthest, 2nd farthest, ..)

The following query uses these:

Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID #defaultView:ScatterChartPREFIXvar_muntype:<http://www.wikidata.org/entity/Q15284>PREFIXvar_area:<http://www.wikidata.org/entity/Q6308>SELECT?from?kilometers?to?rank_groupWHERE{{SELECT(SAMPLE(?mun)AS?mun)(SAMPLE(?mun2)AS?mun2)(SAMPLE(?distNum)AS?kilometers)(COUNT(*)-1AS?rg)(SUBSTR("00",1+STRLEN(STR(?rg)))AS?rgpad)(IF(FLOOR((?rg-(100*FLOOR(?rg/100)))/10)=1,0,?rg-(10*FLOOR(?rg/10)))AS?rgmod)(IF(?rgmod=1,"st",IF(?rgmod=2,"nd",IF(?rgmod=3,"rd","th")))AS?rgord)(CONCAT(?rgpad,STR(?rg),?rgord,"-most farthest places")AS?rank_group)WHERE{{SELECT?mun(SAMPLE(?loc)AS?loc)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}OPTIONAL{{SELECT(?munAS?mun2)(SAMPLE(?loc)AS?loc2)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}OPTIONAL{{SELECT(?munAS?mun3)(SAMPLE(?loc)AS?loc3)WHERE{?munwdt:P31/wdt:P279*var_muntype:;wdt:P131var_area:;wdt:P625?loc.}GROUP BY?mun}}BIND(geof:distance(?loc,?loc2)AS?distNum).BIND(geof:distance(?loc,?loc3)AS?d).FILTER(?distNum>=?d).}GROUP BY?mun?mun2?distNum}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?munrdfs:label?from.?mun2rdfs:label?to.}}ORDER BY?rank_group?kilometers?from= ?d). } GROUP BY ?mun ?mun2 ?distNum } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?mun rdfs:label ?from. ?mun2 rdfs:label ?to. } } ORDER BY ?rank_group ?kilometers ?from<]<)+}"> Try it! Show all Dutch municipalities that share a border with Alphen aan den Rijn (Q213246) , ignoring rankselect?muni?muniLabelwhere{?munip:P31[ps:P31wd:Q2039348];wdt:P47wd:Q213246.SERVICEwikibase:label{bd:serviceParamwikibase:language"nl".}} Try it! Border cities of the world

The following query uses these:

Items: border town (Q902814)    View with Reasonator   View with SQID 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 , coordinate location (P625)    View with Reasonator   View with SQID

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

# To filter by country add FILTER (?country = wd:Qxx)#defaultView:Map# To show the cities of several countries use FILTER (?country IN (wd:Qxx, wd:Qyy))# To obtain cities that are part of a particular continent or territory ?country# should not be optional and add "?country wdt:P361 wd:Qxx ."SELECT?border_city?border_cityLabel?countryLabel?coordsWHERE{?border_citywdt:P31wd:Q902814.OPTIONAL{?border_citywdt:P17?country.}OPTIONAL{?border_citywdt:P625?coords.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?border_cityrdfs:label?border_cityLabel.?countryrdfs:label?countryLabel.}}GROUP BY?border_city?border_cityLabel?countryLabel?coordsorder by?countryLabel?border_cityLabel Try it! RiversLongest rivers

The following query uses these:

Items: river (Q4022)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , length (P2043)    View with Reasonator   View with SQID , image (P18)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID

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

#defaultView:BubbleChartSELECT?item?itemLabel?length?pic?locationWHERE{?itemwdt:P31/wdt:P279*wd:Q4022.?itemwdt:P2043?length.?itemwdt:P18?pic.?itemwdt:P625?locationSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?length)?itemLabelLIMIT50 Try it! Longest river of each continent

The following query uses these:

Items: watercourse (Q355304)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , length (P2043)    View with Reasonator   View with SQID , continent (P30)    View with Reasonator   View with SQID SELECT?continent?river?continentLabel?riverLabelWHERE{{SELECT?continent(MAX(?length)AS?length)WHERE{?riverwdt:P31/wdt:P279*wd:Q355304;wdt:P2043?length;wdt:P30?continent.}GROUP BY?continent}?riverwdt:P31/wdt:P279*wd:Q355304;wdt:P2043?length;wdt:P30?continent.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?continentLabel Try it! Rivers in AntarcticaSELECT?river?riverLabel?locationWHERE{?riverwdt:P31/wdt:P279*wd:Q355304;# watercourse; includes a few creeks – use wd:Q4022 for rivers onlywdt:P30wd:Q51.OPTIONAL{?riverwdt:P625?location.}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Body of water with the most watercourses ending in itItems used: NoneProperties used: mouth of the watercourse (P403) # Bodies of water that most watercourses end in (transitive).# For example, over 4000 watercourses eventually flow into the Ob,# and since the Ob flows into the Kara Sea, the Kara Sea has over 4000 results as well.SELECT?mouth(COUNT(?watercourse)AS?count)WHERE{?watercoursewdt:P403+?mouth.}GROUP BY?mouthORDER BYDESC(?count)LIMIT10 Try it! Bridges over rivers in former government district of Leipzig

The following query uses these:

Items: bridge (Q12280)    View with Reasonator   View with SQID , watercourse (Q355304)    View with Reasonator   View with SQID , Germany (Q183)    View with Reasonator   View with SQID , Saxony (Q1202)    View with Reasonator   View with SQID , Leipzig Government Region (Q24186)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , crosses (P177)    View with Reasonator   View with SQID , country (P17)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID , image (P18)    View with Reasonator   View with SQID , inception (P571)    View with Reasonator   View with SQID , dissolved, abolished or demolished date (P576)    View with Reasonator   View with SQID , located in the administrative territorial entity (P131)    View with Reasonator   View with SQID

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

#defaultView:MapSELECT(SAMPLE(?bridge)AS?bridge)(SAMPLE(?bridgeLabel)AS?bridgeLabel)(SAMPLE(?watercourse)AS?watercourse)(SAMPLE(?watercourseLabel)AS?watercourseLabel)(SAMPLE(?loc)AS?loc)(SAMPLE(?pic)AS?pic)(CONCAT(SAMPLE(?sKey),": ",STR(YEAR(SAMPLE(?s))))AS?start)(CONCAT(SAMPLE(?eKey),": ",STR(YEAR(SAMPLE(?e))))AS?end)(SAMPLE(?article)AS?article)(IF(BOUND(?article),CONCAT(?bridgeLabel," in Wikipedia"),1/0)AS?articleLabel)WHERE{{SELECT?bridge?watercourseWHERE{?bridgewdt:P31/wdt:P279*wd:Q12280;wdt:P177?watercourse.?watercoursewdt:P31/wdt:P279*wd:Q355304.# the following actually yields a perf penalty atm#?bridge wdt:P17 wd:Q183.#OPTIONAL { ?bridge wdt:P17 ?country. }. FILTER(!BOUND(?country) || ?country = wd:Q183).}}# wd:Q1202, wd:Q183 work as well atm and take progressively more time to complete?bridge(p:P131|ps:P131)+wd:Q24186.OPTIONAL{?bridgewdt:P625?loc.}.OPTIONAL{?bridgewdt:P18?pic.}.OPTIONAL{?bridgewdt:P571?s.}.OPTIONAL{?bridgewdt:P576?e.}.OPTIONAL{?articleschema:about?bridge.FILTER(IF(EXISTS{?articleschema:inLanguage"[AUTO_LANGUAGE]".},SUBSTR(str(?article),1,25)="https://[AUTO_LANGUAGE].wikipedia.org/",IF(EXISTS{?articleschema:inLanguage"en".},SUBSTR(str(?article),1,25)="https://en.wikipedia.org/",SUBSTR(str(?article),1,25)="https://de.wikipedia.org/"))).}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,de".?bridgerdfs:label?bridgeLabel.?watercourserdfs:label?watercourseLabel.wd:P571rdfs:label?sKey.wd:P576rdfs:label?eKey.}}GROUP BY?bridge?watercourse Try it! MountainsMountains, with coordinates, not located on EarthItems used: mountain (Q8502) Earth (Q2) Properties used: coordinate location (P625) instance of (P31) SELECTDISTINCT?item?name?coord?lat?lon?globe{?itemwdt:P31wd:Q8502;p:P625[psv:P625[wikibase:geoLatitude?lat;wikibase:geoLongitude?lon;wikibase:geoGlobe?globe;];ps:P625?coord]FILTER(?globe!=wd:Q2)SERVICEwikibase:label{bd:serviceParamwikibase:language"en".?itemrdfs:label?name}}ORDER BYASC(?name) Try it! Highest mountains in the universeItems used: NoneProperties used: elevation above sea level (P2044) coordinate location (P625) #Mountains over 8000 meters elevationSELECT?subj?label?coord?elevWHERE{?subjwdt:P2044?elevfilter(?elev>8000).?subjwdt:P625?coord.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,zh".?subjrdfs:label?label}} Try it! Mountains over 8000 meters elevation elevation above sea level (P2044) SELECT?subj?label?coord?elevWHERE{?subjwdt:P2044?elevfilter(?elev>8000).?subjwdt:P625?coord.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,zh".?subjrdfs:label?label}} Try it! Italian mountains higher than 4000 metersItems used: Italy (Q38) Properties used : elevation above sea level (P2044) coordinate location (P625) country (P17) image (P18) #defaultView:ImageGridSELECT?item?itemLabel?coord?elev?picture{?itemp:P2044/psn:P2044/wikibase:quantityAmount?elev;# normalized heightwdt:P625?coord;wdt:P17wd:Q38;wdt:P18?pictureFILTER(?elev>4000)SERVICEwikibase:label{bd:serviceParamwikibase:language"it"}} Try it! Metro stations in ParisItems used: metro station (Q928830) Paris Métro Line 1 (Q13224) Château de Vincennes (Q585752) Properties used: instance of (P31) connecting line (P81) coordinate location (P625) adjacent station (P197) direction (P560) SELECT?item?itemLabel?adjacent?adjacentL?coords{?itemwdt:P31/wdt:P279*wd:Q928830;wdt:P81wd:Q13224;wdt:P625?coords.OPTIONAL{?itemp:P197[ps:P197?adjacent;pq:P5051wd:Q585752;pq:P81wd:Q13224].?adjacentrdfs:label?adjacentLfilter(lang(?adjacentL)="en")}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?itemLabel Try it! Map of Broadway venuesItems used: Broadway theatre (Q235065) Properties used: Internet Broadway Database venue ID (P1217) coordinate location (P625) #defaultView:Map# Venues in BroadwaySELECTDISTINCT?venue?venueLabel?coords{?venuewdt:P1217?IDBDB.wd:Q235065wdt:P625?broadWayLoc.SERVICEwikibase:around{?venuewdt:P625?coords.bd:serviceParamwikibase:center?broadWayLoc.bd:serviceParamwikibase:radius"1.5".}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! How many states this US state bordersItems used: state of the United States (Q35657) Properties used: instance of (P31) , shares border with (P47) SELECT?state?stateLabel?bordersWHERE{{SELECT?state(COUNT(?otherState)as?borders)WHERE{?statewdt:P31wd:Q35657.?otherStatewdt:P47?state.?otherStatewdt:P31wd:Q35657.}GROUP BY?state}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYDESC(?borders) Try it! Places that are below 10 meters above sea levelItems used: metre (Q11573) Properties used: elevation above sea level (P2044) #defaultView:MapSELECT?place?location?elev?imageWHERE{?placep:P2044/psv:P2044?placeElev.?placeElevwikibase:quantityAmount?elev.?placeElevwikibase:quantityUnit?unit.bind(0.01as?km).filter((?elev<?km*1000&&?unit=wd:Q11573)||(?elev<?km*3281&&?unit=wd:Q3710)||(?elev<?km&&?unit=wd:Q828224)).?placewdt:P625?location.optional{?placewdt:P18?image}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Globes used to represent coordinatesSELECT(count(?v)as?c)?globeWHERE{?vwikibase:geoGlobe?globe}GROUP BY?globeORDER BYDESC(?c) Try it! Places within 1km of the Empire State BuildingItems used: Empire State Building (Q9188) Properties used: coordinate location (P625) instance of (P31) SELECT?place?placeLabel?location?instanceLabelWHERE{wd:Q9188wdt:P625?loc.SERVICEwikibase:around{?placewdt:P625?location.bd:serviceParamwikibase:center?loc.bd:serviceParamwikibase:radius"1".}OPTIONAL{?placewdt:P31?instance}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}BIND(geof:distance(?loc,?location)as?dist)}ORDER BY?dist Try it! Select French municipalities by INSEE code (select by identifier)Properties used: INSEE municipality code (P374) SELECT?item?itemLabel?inseeCode{?itemwdt:P374?inseeCode.FILTER(?inseeCodein("75056","69123","13055"))SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Map and list of municipalities in The Netherlands#Concise list & map of the 355 Dutch municipalities, their geo coordinates and their provinces, per 1-1-2019#See also: #https://almanak.overheid.nl/organisaties/Gemeenten/ - 355 in aantal#https://nl.wikipedia.org/wiki/Lijst_van_Nederlandse_gemeenten - 355 in aantal#defaultView:Mapselect?muni?muniLabel?locationwhere{?munip:P31?instanceOf;# Get statement because we need this laterwdt:P625?location.# And location?instanceOfps:P31wd:Q2039348.# P31 should be 'municipality of the Netherlands'minus{?muniwdt:P31wd:Q7265977.}# Don't show former municipalitiesminus{?instanceOfpq:P582?endTime.}# And don't show municipalities that have an end timeservicewikibase:label{bd:serviceParamwikibase:language"nl".}# Show names in Dutch} Try it! Emergency numbers by population using themItems used : emergency telephone number (Q694554) country (Q6256) Properties used: instance of (P31) population (P1082) emergency phone number (P2852) subclass of (P279) phone number (P1329) #Lists emergency numbers and the total amount of people which can use them#defaultView:BubbleChartSELECT?emergencyNumber?emergencyNumberLabel?tel?population?countriesWHERE{?emergencyNumberwdt:P31wd:Q694554.OPTIONAL{SELECT?emergencyNumber(COUNT(?state)as?countries)(SUM(?pop)as?population)WHERE{?statewdt:P2852?emergencyNumber.OPTIONAL{?statewdt:P1082?pop}.?statewdt:P31/wdt:P279*wd:Q6256}GROUP BY?emergencyNumber}.OPTIONAL{?emergencyNumberwdt:P1329?tel}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BYDESC(?population) Try it! German states, ordered by the number of company headquarters per million inhabitantsItems used: state of Germany (Q1221156) business (Q4830453) Properties used: headquarters location (P159) instance of (P31) subclass of (P279) headquarters location (P159) located in the administrative territorial entity (P131) dissolved, abolished or demolished date (P576) population (P1082) # German states, ordered by the number of company headquarters per million inhabitants# Replace wd:Q1221156 (state of Germany) by anything else you care about, e.g., wd:Q6256 (country)# Nested queries for correctness (don't count companies twice) and performance (aggregate before adding more data)# Limits: states without population missing; company data in Wikidata is always incomplete# Note: This query shows some not-so-easy nesting of DISTINCT (don't count any company twice) and aggregate, in combination with arithmetic output evaluation functions. It is a hard query that may time out if modified.SELECT?state?stateLabel?companies?population(?companies/?population*1000000AS?companiesPerM)WHERE{{SELECT?state(count(*)as?companies)WHERE{{SELECTDISTINCT?company?stateWHERE{?statewdt:P31wd:Q1221156.?companywdt:P31/wdt:P279*wd:Q4830453.?companywdt:P159/wdt:P131*?state.FILTERNOT EXISTS{?companywdt:P576?date}# don't count dissolved companies}}}GROUP BY?state}?statewdt:P1082?populationSERVICEwikibase:label{bd:serviceParamwikibase:language"de"}}ORDER BYDESC(?companiesPerM) Try it! Popular names per birthplace#defaultView:BubbleChartSELECT?cid?firstname(COUNT(*)AS?count)WHERE{?pidwdt:P19wd:Q64.?pidwdt:P735?cid.OPTIONAL{?cidrdfs:label?firstnameFILTER((LANG(?firstname))="en")}}GROUP BY?cid?firstnameORDER BYDESC(?count)?firstnameLIMIT50 Try it! Map of places mentioned in travel stories with text in French accessible onlineItems used: travel book (Q1164267) book (Q571) South Pole (Q933) French (Q150) Properties used: genre (P136) instance of (P31) author (P50) narrative location (P840) coordinate location (P625) full work available at URL (P953) original language of film or TV show (P364) edition or translation of (P629) language of work or name (P407) #defaultView:MapSELECTDISTINCT?item?itemLabel?ed?edLabel?auteurLabel(year(?dateCreation)as?AnneeCreation)?lieuLabel?coord?lienWHERE{?itemwdt:P136wd:Q1164267.# genre :récit de voyage?itemwdt:P31wd:Q571.# nature : livreOPTIONAL{?itemwdt:P50?auteur.# [option] auteur}OPTIONAL{?itemwdt:P571?dateCreation.# [option] date de création }?itemwdt:P840?lieu.# lieu de l'actionMINUS{?itemwdt:P840wd:Q933}# (bug du Pôle Sud)?lieuwdt:P625?coord.# coordonnées géographiques du lieu{?itemwdt:P953?lien.# URL, texte intégral disponible sur?itemwdt:P407wd:Q150# langue de l'œuvre : français}UNION{?edwdt:P629?item.# édition du livre?edwdt:P953?lien.# URL, texte intégral disponible sur ?edwdt:P407wd:Q150# langue de l'œuvre : français}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],fr".}}ORDER BY?dateCreation Try it! Things located where the equator meets the prime meridianItems used: Soul buoy (Q24041662) Properties used: coordinate location (P625) SELECT?place?placeLabel?locationWHERE{wd:Q24041662wdt:P625?loc00.SERVICEwikibase:around{?placewdt:P625?location.bd:serviceParamwikibase:center?loc00.bd:serviceParamwikibase:radius"0.001".}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?placeLabel Try it! French communes with names ending in ac#defaultView:MapSELECT?item?itemLabel?coordWHERE{?itemwdt:P31/wdt:P279*wd:Q484170;wdt:P17wd:Q142;rdfs:label?itemLabel;wdt:P625?coord;FILTER(lang(?itemLabel)="fr").FILTERregex(?itemLabel,"ac$").FILTERnot exists{?itemwdt:P131wd:Q33788}# excluding Koumac, New Caledonia...} Try it! Buildings in more than one countrySELECT?item?itemLabel?countWHERE{{SELECT?item(COUNT(DISTINCT?country)AS?count)WHERE{?itemwdt:P31/wdt:P279*wd:Q41176.?itemwdt:P17?country.FILTERNOT EXISTS{?countrywdt:P576?end}}GROUP BY?item}FILTER(?count>1)SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?count)?itemL Try it! Streets named after a personSELECT?street?streetLabel?cityLabel?personLabelWHERE{?streetwdt:P31wd:Q79007.?streetwdt:P17wd:Q142.?streetwdt:P131?city.?streetwdt:P138?person.?personwdt:P31wd:Q5SERVICEwikibase:label{bd:serviceParamwikibase:language"fr"}}ORDER BY?city Try it! Streets in France without a citySELECT?street?streetLabelWHERE{?streetwdt:P31/wdt:P279*wd:Q79007.?streetwdt:P17wd:Q142.MINUS{?streetwdt:P131[]}.SERVICEwikibase:label{bd:serviceParamwikibase:language"fr"}}ORDER BY?streetLabel Try it! ATMs around Munich belonging to the Bankcard-Servicenetz interbank network (federated query)#defaultView:Map{"hide":["?atm","?geometry"], "layer": "?bankLabel"}PREFIXlgdo:<http://linkedgeodata.org/ontology/>PREFIXgeom:<http://geovocab.org/geometry#>PREFIXbif:<bif:>SELECT?atm?geometry?bank?bankLabelWHERE{hint:Queryhint:optimizer"None".SERVICE<http://linkedgeodata.org/sparql>{{?atmalgdo:Bank;lgdo:atmtrue.}UNION{?atmalgdo:Atm.}?atmgeom:geometry[geo:asWKT?geometry];lgdo:operator?operator.FILTER(bif:st_intersects(?geometry,bif:st_point(11.5746898,48.1479876),5))# 5 km around Munich}BIND(STRLANG(?operator,"de")as?bankLabel)?bankrdfs:label?bankLabel.# bank is part of the Bankcard service network, either via an explicit statement or implicitly due to its legal form (unless explicitly excluded){?bankwdt:P527wd:Q806724.}UNION{?bankwdt:P1454wd:Q5349747.}MINUS{wd:Q806724wdt:P3113?bank.}} PREFIX geom: PREFIX bif: SELECT ?atm ?geometry ?bank ?bankLabel WHERE { hint:Query hint:optimizer "None". SERVICE { { ?atm a lgdo:Bank; lgdo:atm true. } UNION { ?atm a lgdo:Atm. } ?atm geom:geometry [geo:asWKT ?geometry]; lgdo:operator ?operator. FILTER(bif:st_intersects(?geometry, bif:st_point(11.5746898, 48.1479876), 5)) # 5 km around Munich } BIND(STRLANG(?operator, "de") as ?bankLabel) ?bank rdfs:label ?bankLabel. # bank is part of the Bankcard service network, either via an explicit statement or implicitly due to its legal form (unless explicitly excluded) { ?bank wdt:P527 wd:Q806724. } UNION { ?bank wdt:P1454 wd:Q5349747. } MINUS { wd:Q806724 wdt:P3113 ?bank. } }<]<)+}"> Try it! Items geographically located around the Wikimedia Foundation office, sorted by distanceSELECT?place?location?distance?placeLabelWHERE{SERVICEwikibase:around{?placewdt:P625?location.bd:serviceParamwikibase:center"Point(-122.399523 37.786952)"^^geo:wktLiteral.bd:serviceParamwikibase:radius"1".bd:serviceParamwikibase:distance?distance.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?distanceLIMIT100 Try it! Ten largest islands in the world# Ten largest islands in the world# Inspired by this infographic: https://redd.it/a6423t#defaultView:ImageGridSELECTDISTINCT?island?islandLabel?islandImageWHERE{# Instances of island (or of subclasses of island)?island(wdt:P31/wdt:P279*)wd:Q23442.# Optionally with an imageOPTIONAL{?islandwdt:P18?islandImage.}# Get the area of the island# Use the psn: prefix to normalize the values to a common unit of area?islandp:P2046/psn:P2046/wikibase:quantityAmount?islandArea.# Use the label service to automatically fill ?islandLabelSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?islandArea)LIMIT10 Try it! City gates in the Dutch province of Zeelandselect?town?townLabel?gate?gateLabelwhere{# Municipalities within the province ?muniwdt:P31wd:Q2039348;wdt:P131wd:Q705.# Instances of city gate located within any of the municipalities?gatewdt:P31wd:Q82117;wdt:P131?muni;# The Location (usually Town) that the gate is inwdt:P276?town.SERVICEwikibase:label{bd:serviceParamwikibase:language"nl".}} Try it! DemographyBirthplaces of humans named Antoine# Coordinates of the birth places of people named Antoine#defaultView:MapSELECT?item?itemLabel?coordWHERE{?itemwdt:P31wd:Q5.# human?itemwdt:P735wd:Q15235674.?itemwdt:P19?place.?placewdt:P625?coord.SERVICEwikibase:label{bd:serviceParamwikibase:language"fr".}} Try it! Average lifespan by occupation# Select the desired columns and get labelsSELECT?occ?occLabel?avgAge?avgBirthYear?countWHERE{{# Group the people by their occupation and calculate ageSELECT?occ(count(?p)as?count)(round(avg(?birthYear))as?avgBirthYear)(avg(?deathYear-?birthYear)as?avgAge)WHERE{{# Get people with occupation + birth/death dates; combine multiple birth/death dates using avgSELECT?p?occ(avg(year(?birth))as?birthYear)(avg(year(?death))as?deathYear)WHERE{?pwdt:P31wd:Q5;wdt:P106?occ;p:P569/psv:P569[wikibase:timePrecision"9"^^xsd:integer;# precision of at least yearwikibase:timeValue?birth;];p:P570/psv:P570[wikibase:timePrecision"9"^^xsd:integer;# precision of at least yearwikibase:timeValue?death;].}GROUP BY?p?occ}}GROUP BY?occ}FILTER(?count>300)# arbitrary number to weed out values with 'few' observationsSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYASC(?avgAge) 300) # arbitrary number to weed out values with 'few' observations SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } ORDER BY ASC(?avgAge)<]<)+}"> Try it! Items with the most birth datesSELECT?person(COUNT(?date)AS?dateC){?personwdt:P569?date}GROUP BY?personHAVING(?dateC>2)ORDER BYDESC(?dateC)LIMIT100 Try it! Things/people with most childrenSELECT?parent?parentLabel?countWHERE{{SELECT?parent(COUNT(?child)AS?count)WHERE{?parentwdt:P40?child.}GROUP BY?parentORDER BYDESC(?count)LIMIT10}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?count)LIMIT10 Try it! Population growth in Suriname from 1960 onward#defaultView:LineChartSELECT?year?population{wd:Q730p:P1082?p.?ppq:P585?year;ps:P1082?population.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?year Try it! Number of dead people by month since 2000SELECT?yearmonth(COUNT(?person)as?count)WHERE{?personwdt:P31wd:Q5;p:P570/psv:P570[wikibase:timePrecision?precision;wikibase:timeValue?date;].BIND(CONCAT(STR(YEAR(?date)),"-",STR(MONTH(?date)))as?yearmonth).FILTER(?date>="2000-01-01T00:00:00"^^xsd:dateTime)FILTER(?precision>="10"^^xsd:integer)# precision of at least month}GROUP BY?yearmonth= "2000-01-01T00:00:00"^^xsd:dateTime ) FILTER( ?precision >= "10"^^xsd:integer ) # precision of at least month } GROUP BY ?yearmonth<]<)+}"> Try it! PoliticsElectionsThe NetherlandsCandidates for the Dutch general election in 2017

The following query uses these:

Items: 2017 Dutch general election (Q16061881)    View with Reasonator   View with SQID Properties: Twitter username (P2002)    View with Reasonator   View with SQID , P2035 , candidacy in election (P3602)    View with Reasonator   View with SQID , series ordinal (P1545)    View with Reasonator   View with SQID , represents (P1268)    View with Reasonator   View with SQID SELECT?item?itemLabel?twitter?LinkedIN?politieke_partij?politieke_partijLabel?positie_op_lijstWHERE{?itemp:P3602?node.OPTIONAL{?itemwdt:P2002?twitter}OPTIONAL{?itemwdt:P2035?LinkedIN}?nodeps:P3602wd:Q16061881.OPTIONAL{?nodepq:P1545?positie_op_lijst}OPTIONAL{?nodepq:P1268?politieke_partij}OPTIONAL{?nodepq:P2035?LinkedIN}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl"}} Try it! Gender distribution in the candidates for the Dutch general election 2017

The following query uses these:

Items: 2017 Dutch general election (Q16061881)    View with Reasonator   View with SQID Properties: sex or gender (P21)    View with Reasonator   View with SQID , candidacy in election (P3602)    View with Reasonator   View with SQID , series ordinal (P1545)    View with Reasonator   View with SQID , represents (P1268)    View with Reasonator   View with SQID #Kandidaten voor de Nederlandse tk verkiezingen van 2017#defaultView:DimensionsSELECT?positie_op_lijst?genderLabel?politieke_partijLabelWHERE{?itemp:P3602?node.?itemwdt:P21?gender.?nodeps:P3602wd:Q16061881.?nodepq:P1545?positie_op_lijst.?nodepq:P1268?politieke_partij.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl".}} Try it! Candidates for the Dutch general election 2017 living in Antwerp, Belgium

The following query uses these:

Items: Antwerp (Q12892)    View with Reasonator   View with SQID , 2017 Dutch general election (Q16061881)    View with Reasonator   View with SQID Properties: residence (P551)    View with Reasonator   View with SQID , Twitter username (P2002)    View with Reasonator   View with SQID , P2035 , candidacy in election (P3602)    View with Reasonator   View with SQID , series ordinal (P1545)    View with Reasonator   View with SQID , represents (P1268)    View with Reasonator   View with SQID SELECT?item?itemLabel?twitter?LinkedIN?politieke_partij?politieke_partijLabel?positie_op_lijstWHERE{?itemp:P3602?node.?itemwdt:P551wd:Q12892.OPTIONAL{?itemwdt:P2002?twitter.}OPTIONAL{?itemwdt:P2035?LinkedIN.}?nodeps:P3602wd:Q16061881.OPTIONAL{?nodepq:P1545?positie_op_lijst.}OPTIONAL{?nodepq:P1268?politieke_partij.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl".}} Try it! Candidates for the Dutch general election 2017 living abroad

The following query uses these:

Items: 2017 Dutch general election (Q16061881)    View with Reasonator   View with SQID , Netherlands (Q55)    View with Reasonator   View with SQID Properties: residence (P551)    View with Reasonator   View with SQID , country (P17)    View with Reasonator   View with SQID , coordinate location (P625)    View with Reasonator   View with SQID , candidacy in election (P3602)    View with Reasonator   View with SQID

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

#defaultView:MapSELECT?item?itemLabel?coordinatesWHERE{?itemp:P3602?node.?itemwdt:P551?residence.?residencewdt:P17?country;wdt:P625?coordinates.?nodeps:P3602wd:Q16061881.FILTER(?country!=wd:Q55)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl".}} Try it! Occupations of candidates of the Dutch general election 2017

The following query uses these:

Items: Democrats 66 (Q747910)    View with Reasonator   View with SQID , Labour Party (Q275441)    View with Reasonator   View with SQID , 2017 Dutch general election (Q16061881)    View with Reasonator   View with SQID Properties: sex or gender (P21)    View with Reasonator   View with SQID , occupation (P106)    View with Reasonator   View with SQID , candidacy in election (P3602)    View with Reasonator   View with SQID , series ordinal (P1545)    View with Reasonator   View with SQID , represents (P1268)    View with Reasonator   View with SQID #Kandidaten voor de Nederlandse TK verkiezingen van 2017#defaultView:DimensionsSELECT?positie_op_lijst?genderLabel?occupationLabel?politieke_partijLabelWHERE{VALUES?politieke_partij{wd:Q747910wd:Q275441}?itemp:P3602?node.?itemwdt:P21?gender.?itemwdt:P106?occupation.?nodeps:P3602wd:Q16061881.?nodepq:P1545?positie_op_lijst.?nodepq:P1268?politieke_partij.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl".}} Try it! Gender balance of members of Irish parliamentItems used: Teachta Dála (Q654291) Properties used: position held (P39) sex or gender (P21) SELECT?genderlabel(COUNT(?genderlabel)as?total)WHERE{?subjwdt:P39wd:Q654291.?subjwdt:P21?gender.?genderrdfs:label?genderlabelfilter(lang(?genderlabel)="en").?subjrdfs:label?labelfilter(lang(?label)="en")}GROUP BY?genderlabel Try it! Assemblies by number of seatsItems used: assembly (Q1752346) Properties used: instance of (P31) subclass of (P279) number of seats (P1342) applies to jurisdiction (P1001) inception (P571) dissolved, abolished or demolished date (P576) SELECTDISTINCT?item?title?seats?jurisdiction(YEAR(?inception)AS?start)(YEAR(?dissolution)AS?end)WHERE{?itemwdt:P31/wdt:P279*wd:Q1752346.OPTIONAL{?itemwdt:P1342?seats.}OPTIONAL{?itemwdt:P1001?j.?jrdfs:label?jurisdictionfilter(lang(?jurisdiction)="en").}OPTIONAL{?itemwdt:P571?inception.}OPTIONAL{?itemwdt:P576?dissolution.}OPTIONAL{?itemrdfs:label?titlefilter(lang(?title)="en").}}ORDER BYDESC(?seats)?title Try it! List of countries by age of the head of governmentItems used: sovereign state (Q3624078) historical country (Q3024240) Properties used: instance of (P31) head of government (P6) end time (P582) date of birth (P569) #added by Jura1, rev. 2016-11-08SELECTDISTINCT?age?country?countryLabel?hgovernment?hgovernmentLabel{?countrywdt:P31wd:Q3624078.FILTERNOT EXISTS{?countrywdt:P31wd:Q3024240}?countryp:P6?statement.?statementps:P6?hgovernment.?countrywdt:P6?hgovernment.FILTERNOT EXISTS{?statementpq:P582?x}?hgovernmentwdt:P569?dob.BIND(YEAR(now())-YEAR(?dob)as?age)FILTER(?age>=65)SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BYDESC(?age) Try it! Number of ministers who are themselves children of a minister, per countryItems used: human (Q5) minister (Q83307) Properties used: instance of (P31) position held (P39) subclass of (P279) father (P22) mother (P25) country of citizenship (P27) SELECT?cc(COUNT(DISTINCT?child)AS?number){?childwdt:P31wd:Q5;# Looking for real humans and not fictional oneswdt:P39/wdt:P279*wd:Q83307;(wdt:P22|wdt:P25)[wdt:P39/wdt:P279*wd:Q83307];wdt:P27/wdt:P901?cc}GROUP BY?ccORDER BYDESC(?number) Try it! Members of the French National Assembly born out of FranceItems used: member of the French National Assembly (Q3044918) France (Q142) Properties used: position held (P39) place of birth (P19) country (P17) France (Q142) SELECTDISTINCT?item?itemLabel?placeLabel?countryLabelWHERE{?itemwdt:P39wd:Q3044918.?itemwdt:P19?place.?placewdt:P17?country.FILTERNOT EXISTS{?placewdt:P17wd:Q142.}SERVICEwikibase:label{bd:serviceParamwikibase:language"fr".}}ORDER BY?countryLabel?itemLabel Try it! List of parliament buildings with pictures by countryItems used: parliament building (Q7138926) Properties used: country (P17) image (P18) instance of (P31) #defaultView:ImageGridSELECT?building?buildingLabel?country?countryLabel?pictureWHERE{?buildingwdt:P31wd:Q7138926.?buildingwdt:P18?picture.OPTIONAL{?buildingwdt:P17?country}.#if availableSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?countryLabelLIMIT188 Try it! Number of jurisdictions by driving sideSELECT?sideLabel(COUNT(?jurisdiction)AS?count)WHERE{?jurisdictionwdt:P1622?side.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?sideLabelORDER BY?sideLabel Try it! Timeline of mayors of Amsterdam, the Netherlands#defaultView:Timelineselect?mayor?mayorLabel?start?endwhere{?mayorp:P39?position.?positionps:P39wd:Q13423495;pq:P580?start;pq:P582?end.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],nl,en".}} Try it! Current U.S. members of the Senate with district, party and date they assumed officeselect?senator?senatorLabel?districtLabel?partyLabel?assumedOffice(sample(?image)as?image)where{# Get all senators?senatorp:P39?posheld;# With position heldp:P102?partystatement.# And with a certain party# Get the party?partystatementps:P102?party.minus{?partystatementpq:P582?partyEnd.}# but minus the ones the senator is no longer a member ofminus{?partywdt:P361?partOf.}# and the 'Minnesota Democratic–Farmer–Labor Party' and such# Check on the position in the senate?posheldps:P39wd:Q4416090;# Position held is in the senatepq:P768?district;pq:P580?assumedOffice.# And should have a starttimeminus{?posheldpq:P582?endTime.}# But not an endtime # Add an imageoptional{?senatorwdt:P18?image.}servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}group by?senator?senatorLabel?districtLabel?partyLabel?assumedOfficeorder by?senatorLabel Try it! Economic and BusinessMap of places of birth of dead economists, colour-coded by era#defaultView:MapSELECTDISTINCT?person?name?birthplace?birthyear?coord?layerWHERE{{?personwdt:P106wd:Q188094}UNION{?personwdt:P101wd:Q8134}?personwdt:P570?dod;wdt:P19?place.?placewdt:P625?coordOPTIONAL{?personwdt: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)?personrdfs:label?namefilter(lang(?name)="en")?placerdfs:label?birthplacefilter(lang(?birthplace)="en")}ORDER BY?birthyear Try it! Distinct Billionaires# 2018-05-10: 93 resultsSELECT?locationLabel?item?itemLabel(MAX(?billions)as?billions)WHERE{?itemwdt:P2218?worth.?itemwdt:P19?location.FILTER(?worth>1000000000).BIND(?worth/1000000000AS?billions).SERVICEwikibase:label{bd:serviceParamwikibase:language"en,de".}}GROUP BY?locationLabel?item?itemLabelORDER BYDESC(?billions) Try it! ScienceBiology and MedicineDiseasesThe number of existing translations for diseases in Wikidata

Items used: disease (Q12136)

SELECT?disease?doid?enLabel(count(?language)as?languages)WHERE{?diseasewdt:P699?doid;rdfs:label?label;rdfs:label?enLabel.FILTER(lang(?enLabel)="en")BIND(lang(?label)AS?language)}group by?disease?doid?enLabelorder bydesc(?languages) Try it! A network of Drug-disease interactions on infectious diseases (Source: Disease Ontology, NDF-RT and ChEMBL)#defaultView:GraphSELECTDISTINCT?item?itemLabel?rgb?linkWHERE{VALUES?toggle{truefalse}?diseasewdt:P699?doid;wdt:P279+wd:Q18123741;wdt:P2176?drug.?drugrdfs:label?drugLabel.FILTER(LANG(?drugLabel)="en").?diseaserdfs:label?diseaseLabel.FILTER(LANG(?diseaseLabel)="en").BIND(IF(?toggle,?disease,?drug)AS?item).BIND(IF(?toggle,?diseaseLabel,?drugLabel)AS?itemLabel).BIND(IF(?toggle,"FFA500","7FFF00")AS?rgb).BIND(IF(?toggle,"",?disease)AS?link).} Try it! The number of Wikidata items on Diseases and the percentage of those with a pointer to the Disease OntologySELECT(COUNT(?disease)AS?total)(SUM(?ref)AS?byDO)(100*?byDO/?totalAS?percent)WHERE{{?diseasewdt:P31wd:Q12136}UNION{?diseasewdt:P279wd:Q12136.}OPTIONAL{?diseasep:P699?statement.BIND(1AS?ref).}} Try it! GenesHuman genes updated this weekSELECTDISTINCT?item?ncbi_gene?date_modifiedWHERE{?itemwdt:P351?ncbi_gene;wdt:P703wd:Q15978631;schema:dateModified?date_modified.BIND(now()-?date_modifiedas?date_range)FILTER(?date_range<8)} Try it! VariantsCounts of gene-variant types sourced from the CIViC database#defaultView:BarChartSELECT?variant_typeLabel(count(?variant_typeLabel)as?counts)WHERE{?itemwdt:P3329?civic_id;wdt:P31?variant_type.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}GROUP BY?variant_typeLabelORDER BY?counts Try it! Which variant of which gene predicts a positive prognosis in colorectal cancerSELECT?geneLabel?variantLabelWHERE{VALUES?disease{wd:Q188874}?variantwdt:P3358?disease;# P3358 Positive prognostic predictorwdt:P3433?gene.# P3433 biological variant ofSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Variants that are associated with renal cell carcinoma# variants that are associated with renal cell carcinomaSELECTDISTINCT?civic_id?item?itemLabelWHERE{VALUES?property{wdt:P3356# positive diagnostic predictorwdt:P3357# negative diagnostic predictorwdt:P3358# positive prognostic predicatorwdt:P3359# negative prognostic predictor}?itemwdt:P3329?civic_id.{?item?propertywd:Q1164529.}# wd:Q1164529 = renal cell carcinomaUNION{?itemp:P3354?o.# positive therapeutic predictor?opq:P2175wd:Q1164529.}UNION{?itemp:P3354?o.# negative therapeutic predictor?opq:P2175wd:Q1164529.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! PubMed references in CIViCdb# variants that are associated with renal cell carcinomaSELECTDISTINCT?reference?referenceLabel?pmidWHERE{?itemwdt:P3329?civicId;?property?object.?objectprov:wasDerivedFrom?provenance.?provenancepr:P248?reference.?referencewdt:P31wd:Q13442814;wdt:P698?pmid.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Variant counts by predictor type#defaultView:BubbleChartSELECT?propertyLabel(count(?prognostic_type)as?counts)WHERE{VALUES?prognostic_type{wdt:P3354wdt:P3355wdt:P3356wdt:P3357wdt:P3358wdt:P3359}?itemwdt:P3329?civic_id;?prognostic_type?prognostic_value.?propertywikibase:directClaim?prognostic_type.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}GROUP BY?propertyLabel?prognostic_typeLabelORDER BY?counts Try it! ProteinsGet Wikidata - UniprotId mappings for homo sapiensSELECT?item?itemLabel?uniprotid?tax_nodeWHERE{?itemwdt:P352?uniprotid;wdt:P703wd:Q15978631.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! MetabolitesMetabolites and the species where they are found inPREFIXpr:<http://www.wikidata.org/prop/reference/>PREFIXrdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIXprov:<http://www.w3.org/ns/prov#>SELECT?compound?compoundLabel?speciesLabel?sourceLabel?doi?wpidWHERE{?compoundwdt:P31wd:Q11173.MINUS{?compoundwdt:P31wd:Q8054.}?compoundp:P703?statement.?statementrdf:typewikibase:BestRank.?statementps:P703?species.OPTIONAL{?statement(prov:wasDerivedFrom/pr:P248)?source.OPTIONAL{?sourcewdt:P2410?wpid.}OPTIONAL{?sourcewdt:P356?doi.}}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYASC(?compound) Try it! Metabolite-metabolite interactions (mostly conversions) and their pKa change

Federated query using the WikiPathways SPARQL endpoint to retrieve interaction information. The dimensions plot show the pKa changes during metabolite-metabolite interaction. It must be noted here that many very basic or very acidic are reported in pathways as the uncharged structure, whereas in normal biological pathways these compounds are charged and then have quite different pKa charges.

#defaultView:DimensionsPREFIXwdt:<http://www.wikidata.org/prop/direct/>PREFIXwp:<http://vocabularies.wikipathways.org/wp#>PREFIXdcterms:<http://purl.org/dc/terms/>SELECTDISTINCT?wpid?metaboliteLabel?pKa?pKa2?metabolite2Label?wpid2WITH{SELECT?wpid?source_pathway?metabolite?pKa?pKa2?metabolite2?wpid2WHERE{# VALUES ?wpid { "WP550" }?pathwaywdt:P2410?wpid;wdt:P527?metabolite;wdt:P2888?source_pathway.?metabolitewdt:P1117?pKa.SERVICE<http://sparql.wikipathways.org/sparql>{?wp_mb1wp:bdbWikidata?metabolite.?wp_mb1dcterms:isPartOf?interaction.?interactionrdf:typewp:Interaction.?wp_mb2dcterms:isPartOf?interaction.?wp_mb2wp:bdbWikidata?metabolite2.FILTER(?wp_mb1!=?wp_mb2)}}}AS%resultWHERE{INCLUDE%result?metabolite2wdt:P1117?pKa2.?pathway2wdt:P2410?wpid2;wdt:P527?metabolite2;SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} { ?wp_mb1 wp:bdbWikidata ?metabolite . ?wp_mb1 dcterms:isPartOf ?interaction . ?interaction rdf:type wp:Interaction . ?wp_mb2 dcterms:isPartOf ?interaction . ?wp_mb2 wp:bdbWikidata ?metabolite2 . FILTER (?wp_mb1 != ?wp_mb2) } } } AS %result WHERE { INCLUDE %result ?metabolite2 wdt:P1117 ?pKa2 . ?pathway2 wdt:P2410 ?wpid2 ; wdt:P527 ?metabolite2 ; SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }<]<)+}"> Try it! TaxonAsterophryinae parent taxon reverse graph#defaultView:GraphPREFIXgas:<http://www.bigdata.com/rdf/gas#>SELECT?item?itemLabel?pic?linkToWHERE{SERVICEgas:service{gas:programgas:gasClass"com.bigdata.rdf.graph.analytics.SSSP";gas:inwd:Q1968598;gas:traversalDirection"Reverse";gas:out?item;gas:out1?depth;gas:maxIterations3;gas:linkTypewdt:P171.}OPTIONAL{?itemwdt:P171?linkTo}OPTIONAL{?itemwdt:P18?pic}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! PathwaysAll human pathways from WikipathwaysSELECT?pathway?pathwayLabel?wpidWHERE{?pathwaywdt:P2410?wpid;wdt:P703wd:Q15978631.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Biomarkers in Wikidata which interact with proteins in human pathways from Wikipathwaysprefixvoid:<http://rdfs.org/ns/void#>prefixpav:<http://purl.org/pav/>prefixxsd:<http://www.w3.org/2001/XMLSchema#>prefixfreq:<http://purl.org/cld/freq/>prefixbiopax:<http://www.biopax.org/release/biopax-level3.owl#>prefixskos:<http://www.w3.org/2004/02/skos/core#>prefixrdfs:<http://www.w3.org/2000/01/rdf-schema#>prefixrdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>prefixgpml:<http://vocabularies.wikipathways.org/gpml#>prefixwp:<http://vocabularies.wikipathways.org/wp#>prefixdcterms:<http://purl.org/dc/terms/>prefixwprdf:<http://rdf.wikipathways.org/>prefixprov:<http://www.w3.org/ns/prov#>prefixfoaf:<http://xmlns.com/foaf/0.1/>prefixdc:<http://purl.org/dc/elements/1.1/>SELECTDISTINCT?biomarkerLabel?proteinLabel?geneID?WP_gene?PathwayID?PathwayName#results that are displayed.WHERE{VALUES?biomarker{wd:Q420633wd:Q27125809wd:Q422462}#you can add more biomarkers here if needed, separated by a space.?biomarkerwdt:P31wd:Q11173.#Stating that all biomarkers have to be "instance of" "chemical compound" (you could ommit this, but query will probably take longer).?biomarkerwdt:P638?pdbID.#Checking if a biomarker has a Protein Databank ID (PDB) -> meaning the metabolite can interact with a protein.?proteinwdt:P31wd:Q8054.#Stating that all proteins are "instance of" "protein"?proteinwdt:P638?pdbID.#Checking which proteins have a PDB ID, which we queried previously in relationship to the biomarkers.?proteinwdt:P702?gene.#Connecting the protein to a gene ("encoded by" relationship) -> to get an identifier we can use later in federated WikiPathways query.?genewdt:P703wd:Q15978631.#Now removing all genes that are not found in species "Homo sapiens". -> This info is not always available for proteins in WikiData.?genewdt:P2888?geneID.#Getting the "exact match" identifier for the gene, related to the protein, related to the biomarker.SERVICE<http://sparql.wikipathways.org/sparql>{#Connecting to the WikiPathways SPARQL endpoint.?WP_pathwayawp:Pathway.#Stating a ?WP_pathway is indeed a pathway in the WikiPathways RDF .?WP_pathwaywp:organismName"Homo sapiens"^^xsd:string.#Removing all PWs not for species Homo sapiens.?WP_pathwaydc:identifier?PathwayID.#Query the identifier of the pathway in WPs.?WP_pathwaydc:title?PathwayName.#Obtaining the name of the pathway. ?WP_geneawp:Protein.#Stating that a ?WP_gene is a Protein DataNode (you could ommit this, to also get all DataNodes modeled as GeneProducts out, but query will take longer).?WP_genewp:bdbEntrezGene?geneID.#Connecting the previously queried "exact match" from WikiData to the NCBI/Entrez Gene ID in WPs. ?WP_genedcterms:isPartOf?WP_pathway.#Connecting the WP_gene to the WP_pathway.}OPTIONAL{?biomarkerrdfs:label?biomarkerLabel.#Create a label (aka name) for the biomarkers in WikiData, without using the service query. FILTER(LANG(?biomarkerLabel)="en").}OPTIONAL{?proteinrdfs:label?proteinLabel.#Create a label(aka name) for the proteins in WikiData, without using the service query.FILTER(LANG(?proteinLabel)="en").}}ORDER BYDESC(?biomarkerLabel)#Order results for biomarkers meaning the metabolite can interact with a protein. ?protein wdt:P31 wd:Q8054 . #Stating that all proteins are "instance of" "protein" ?protein wdt:P638 ?pdbID . #Checking which proteins have a PDB ID, which we queried previously in relationship to the biomarkers. ?protein wdt:P702 ?gene . #Connecting the protein to a gene ("encoded by" relationship) -> to get an identifier we can use later in federated WikiPathways query. ?gene wdt:P703 wd:Q15978631 . #Now removing all genes that are not found in species "Homo sapiens". -> This info is not always available for proteins in WikiData. ?gene wdt:P2888 ?geneID . #Getting the "exact match" identifier for the gene, related to the protein, related to the biomarker. SERVICE { #Connecting to the WikiPathways SPARQL endpoint. ?WP_pathway a wp:Pathway . #Stating a ?WP_pathway is indeed a pathway in the WikiPathways RDF . ?WP_pathway wp:organismName "Homo sapiens"^^xsd:string . #Removing all PWs not for species Homo sapiens. ?WP_pathway dc:identifier ?PathwayID . #Query the identifier of the pathway in WPs. ?WP_pathway dc:title ?PathwayName . #Obtaining the name of the pathway. ?WP_gene a wp:Protein . #Stating that a ?WP_gene is a Protein DataNode (you could ommit this, to also get all DataNodes modeled as GeneProducts out, but query will take longer). ?WP_gene wp:bdbEntrezGene ?geneID . #Connecting the previously queried "exact match" from WikiData to the NCBI/Entrez Gene ID in WPs. ?WP_gene dcterms:isPartOf ?WP_pathway . #Connecting the WP_gene to the WP_pathway. } OPTIONAL {?biomarker rdfs:label ?biomarkerLabel. #Create a label (aka name) for the biomarkers in WikiData, without using the service query. FILTER(LANG(?biomarkerLabel) = "en"). } OPTIONAL {?protein rdfs:label ?proteinLabel. #Create a label(aka name) for the proteins in WikiData, without using the service query. FILTER(LANG(?proteinLabel) = "en"). } } ORDER BY DESC (?biomarkerLabel) #Order results for biomarkers<]<)+}"> Try it! Ranking of most cited work in WikiPathwaysSELECT?citation?citationLabel(count(?pathway)as?times_cited)WHERE{?pathwaywdt:P2410?WikiPathwaysID;wdt:P2860?citation.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?pathway?citation?citationLabel Try it! Gene and metabolite counts per pathway#Gene and metabolite counts per path#defaultView:ScatterChartSELECT?path?genes?metabolites?pathwayWHERE{{SELECTDISTINCT?path(COUNT(?pwPart)AS?genes)WHERE{?pathwdt:P2410?WikipathsID.?pathwdt:P527?pwPart.?pwPartwdt:P31wd:Q7187.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?path?genes}{SELECTDISTINCT?path(COUNT(?pwPart)AS?metabolites)WHERE{?pathwdt:P2410?WikipathsID.?pathwdt:P527?pwPart.?pwPartwdt:P31wd:Q11173.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?path?metabolites}OPTIONAL{?pathrdfs:label?pathway.}}ORDER BYDESC(?genes) Try it! Biological pathways with protein structures in the PDB databaseSELECT?pathway?pathwayLabel?WikiPathways?Reactome(COUNT(DISTINCT?protein)as?count)WHERE{VALUES?pathwayType{wd:Q4915012wd:Q2996394}?pathwaywdt:P31?pathwayType.{?pathwaywdt:P527/wdt:P688?protein.}UNION{?pathwaywdt:P527?protein.}?proteinwdt:P638?PDBID.OPTIONAL{?pathwaywdt:P2410?WikiPathways}OPTIONAL{?pathwaywdt:P3937?Reactome}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}GROUP BY?pathway?pathwayLabel?WikiPathways?ReactomeORDER BYDESC(?count) Try it! Integration queries (with other sources)Get known variants reported in CIViC database (Q27612411) of genes reported in a Wikipathways pathway: Bladder Cancer (Q30230812)

The following query uses these:

Items: bladder cancer (Q504775)    View with Reasonator   View with SQID Properties: WikiPathways ID (P2410)    View with Reasonator   View with SQID , has part (P527)    View with Reasonator   View with SQID , subclass of (P279)    View with Reasonator   View with SQID , CIViC variant ID (P3329)    View with Reasonator   View with SQID , biological variant of (P3433)    View with Reasonator   View with SQID , positive therapeutic predictor (P3354)    View with Reasonator   View with SQID , negative therapeutic predictor (P3355)    View with Reasonator   View with SQID , positive diagnostic predictor (P3356)    View with Reasonator   View with SQID , negative diagnostic predictor (P3357)    View with Reasonator   View with SQID , positive prognostic predictor (P3358)    View with Reasonator   View with SQID , negative prognostic predictor (P3359)    View with Reasonator   View with SQID , medical condition treated (P2175)    View with Reasonator   View with SQID SELECTDISTINCT?pathway?pathwayLabel?pwpart?pwpartLabel?variant?variantLabel?disease?diseaseLabelWHERE{VALUES?predictor{p:P3354p:P3355p:P3356p:P3357p:P3358p:P3359}VALUES?predictorQualifier{pq:P2175}VALUES?wpID{"WP2828"}?pathwaywdt:P2410?wpID;# Pathways has a Wikipathways identifierwdt:P527?pwpart.# which contains pathways parts?diseasewdt:P279+wd:Q504775.# The disease is a subclass of urinary bladder cancer # based on annotations in the Disease ontology?variantwdt:P3329?civicID;# a variant known in CIViC ?predictor?node;# has a predicting relation with diseases# labeled as being a subclass of urinary bladder cancerwdt:P3433?pwpart.# variant is biological variant of{?node?predictorStatement?drug_label;?predictorQualifier?disease.}UNION{?node?predictorStatement?disease.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Federated queriesKnown interaction types in Wikipathways for a pathway with Identifier WP716PREFIXdcterms:<http://purl.org/dc/terms/>PREFIXwp:<http://vocabularies.wikipathways.org/wp#>SELECTDISTINCT?interaction_typeWHERE{VALUES?wpid{"WP716"}?itemwdt:P2410?wpid;wdt:P2888?source_pathway.SERVICE<http://sparql.wikipathways.org/sparql>{?wp_pathwaydc:identifier?source_pathway.?sdcterms:isPartOf?wp_pathway,?interaction.?interactionrdf:typewp:Interaction.?interactionrdf:type?interaction_type.?interactionwp:participants?participants.}} { ?wp_pathway dc:identifier ?source_pathway . ?s dcterms:isPartOf ?wp_pathway, ?interaction . ?interaction rdf:type wp:Interaction . ?interaction rdf:type ?interaction_type . ?interaction wp:participants ?participants . } }<]<)+}"> Try it! Local annotations from Wikipathways using Federated query on a Pathway with identifier WP716

The following query uses these:

Properties: WikiPathways ID (P2410)    View with Reasonator   View with SQID , exact match (P2888)    View with Reasonator   View with SQID PREFIXdcterms:<http://purl.org/dc/terms/>PREFIXwp:<http://vocabularies.wikipathways.org/wp#>SELECTDISTINCT?item?pw_annotationWHERE{VALUES?wpid{"WP716"}?itemwdt:P2410?wpid;wdt:P2888?source_pathway.SERVICE<http://sparql.wikipathways.org/sparql>{?wp_pathwaydc:identifier?source_pathway.?wp_pathwaywp:ontologyTag?pw_annotation.# ?pw_annotation rdfs:label ?annotation_label .}} { ?wp_pathway dc:identifier ?source_pathway . ?wp_pathway wp:ontologyTag ?pw_annotation . # ?pw_annotation rdfs:label ?annotation_label . } }<]<)+}"> Try it! Find drugs for cancers that target genes related to cell proliferation;workedon2018-12-17:)#cases where a drug physically interacts with the product of gene known to be genetically associated a disease#these cases may show opportunities to repurpose a drug for a new disease#See http://database.oxfordjournals.org/content/2016/baw083.long and#http://drug-repurposing.nationwidechildrens.org/search#an example that was recently validated involved a new link between Metformin wd:Q19484 and cancer survival#https://jamia.oxfordjournals.org/content/22/1/179#currently set up to find drugs for cancers that target genes related to cell proliferation#adapt by changing constraints (e.g. to 'heart disease' Q190805) or removing themSELECT?drugLabel?geneLabel?biological_processLabel?diseaseLabelWHERE{?drugwdt:P129?gene_product.# drug interacts with a gene_product?genewdt:P688?gene_product.# gene_product (usually a protein) is a product of a gene (a region of DNA)?diseasewdt:P2293?gene.# genetic association between disease and gene?diseasewdt:P279*wd:Q12078.# limit to cancers wd:Q12078 (the * operator runs up a transitive relation..)?gene_productwdt:P682?biological_process.#add information about the GO biological processes that the gene is related to ?biological_process(wdt:P361|wdt:P279)*wd:Q14818032.# chain down subclass/part-of#Change the last statement (wd:Q14818032) to limit to genes related to certain biological processes (and their sub-processes):#cell proliferation wd:Q14818032 (Current example)#apoptosis wd:Q14599311#uncomment the next line to find a subset of the known true positives (there are not a lot of them in here yet; will lead to 4 drugs if biological process is cell proliferation 2018-12-17)#?disease wdt:P2176 ?drug . # disease is treated by a drugSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}LIMIT1000 Try it! Parent taxons of Blue WhaleItems used: Balaenoptera musculus (Q42196) Properties used: image (P18) parent taxon (P171) #defaultView:GraphSELECT?item?itemLabel?pic?linkToWHERE{wd:Q42196wdt:P171*?itemOPTIONAL{?itemwdt:P171?linkTo}OPTIONAL{?itemwdt:P18?pic}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Mosquito speciesItems used: taxon (Q16521) species (Q7432) Culicidae (Q7367) Properties used: instance of (P31) taxon rank (P105) parent taxon (P171) taxon name (P225) # Species of mosquitoes# added 2017-06SELECT?item?taxonnameWHERE{?itemwdt:P31wd:Q16521;wdt:P105wd:Q7432;wdt:P171*wd:Q7367;wdt:P225?taxonname.} Try it! Taxons and what they are named afterSELECT?taxon?eponym?taxonName?eponymLabelWHERE{?taxonwdt:P31wd:Q16521;wdt:P225?taxonName;wdt:P138?eponym.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?eponym Try it! Biologists with Twitter accountsSELECTDISTINCT?personLabel(CONCAT("https://twitter.com/",?twitterName)AS?twitterlink)?picWHERE{?personwdt:P2002?twitterName;wdt:P106?occupation.OPTIONAL{?personwdt:P18?pic.}?occupationwdt:P279*wd:Q864503.# all subclasses of biologistsSERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Cell lines with names that could also be URLs (Internet of Cell Lines).SELECT*WHERE{{SELECT?cell_line?cell_line_nameWHERE{?cell_linewdt:P31wd:Q21014462;rdfs:label?cell_line_name.FILTER(LANG(?cell_line_name)="en").FilterREGEX(STR(?cell_line_name),"^[\\w\\-\\.]+\\.[A-z]+$")}}?tldwdt:P31/wdt:P279*wd:Q14296;rdfs:label?tld_name.FILTER(LANG(?tld_name)="en").FILTERREGEX(STR(?cell_line_name),CONCAT(REPLACE(?tld_name,"\\.","\\\\."),"$"),"i")BIND(URI(CONCAT("http://",?cell_line_name))as?url)} Try it! List of pharmaceutical drugs with pictureSELECT?moleculeLabel?formule?picture?moleculeWHERE{?moleculewdt:P31wd:Q12140;wdt:P274?formule;wdt:P117?pictureSERVICEwikibase:label{bd:serviceParamwikibase:language"en, de".}}ORDER BY?moleculeLabel Try it! Organisms that are located in the female urogential tract and that have a gene with product indoleItems used: vagina (Q5880) 1H-indole (Q319541) Properties used: location (P276) found in taxon (P703) product or material produced (P1056) SELECT?organism_nameWHERE{?organism_itemwdt:P276wd:Q5880;rdfs:label?organism_name.?genewdt:P703?organism_item;wdt:P1056wd:Q319541.FILTER(LANG(?organism_name)="en").} Try it! Computer Science and TechnologyList of computer files formatsSELECTDISTINCT?idExtension?extension?mediaType?idExtensionLabelWHERE{?idExtensionwdt:P31wd:Q235557;wdt:P1195?extension.OPTIONAL{?idExtensionwdt:P1163?mediaType}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?extension?mediaType Try it! List of W3C standardsSELECTDISTINCT?standard?standardLabel?websiteWHERE{?standardwdt:P1462wd:Q37033.OPTIONAL{?standardwdt:P856?website}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?standardLabel Try it! Oldest softwareSELECT?software?softwareLabel?date(ROUND((NOW()-?date)/365.2425)AS?age){?softwarewdt:P31/wdt:P139*wd:Q7397.OPTIONAL{?softwarewdt:P571?date.}OPTIONAL{?softwarep:P348/pq:P577?date.}FILTER(BOUND(?date)).SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?dateLIMIT10 Try it! Universities of main programming language authorsSELECT?lang?langLabel?human?humanLabel?educatedat?educatedatLabel?coords{?langwdt:P31/wdt:P279*wd:Q9143.?humanwdt:P31wd:Q5.{?langwdt:P287?human}UNION{?langwdt:P170?human}UNION{?langwdt:P943?human}UNION{?langwdt:P178?human}.?humanwdt:P69?educatedat.?educatedatwdt:P625?coords.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,fr"}}LIMIT100 Try it! Websites with OpenAPI endpointsSELECT?database?databaseLabel?license?licenseLabel?valueWHERE{?database?p?wds.OPTIONAL{?databasewdt:P275?license}?wds?v?value.?wdPwikibase:statementProperty?v.?wdPwikibase:claim?p.?wdspq:P31wd:Q27075870.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYASC(?databaseLabel) Try it! E-Readers that support the mobipocket file formatSELECT?ereader?ereaderLabelWHERE{?ereaderwdt:P31wd:Q726235.?ereaderwdt:P1072wd:Q1941622.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Software applications ranked in descending order by the number of writable file formats#defaultView:BubbleChart SELECT?app?appLabel(COUNT(?format)AS?count)WHERE{?app(p:P31/ps:P31/wdt:P279)wd:Q7397.?appwdt:P1072?format.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?app?appLabelORDER BYDESC(?count) Try it! Return a bubble chart of mediatypes by count of file formatsSELECTDISTINCT?mediaType(COUNT(?ff)as?count)WHERE{?ffwdt:P31/wdt:P279*wd:Q235557.?ffwdt:P1163?mediaType.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?mediaTypeORDER BYDESC(?count) Try it! Erdos Numbers and images of people who have oral histories in the Computer History Museum's collection#defaultView:ImageGridSELECT?personLabel?image?ErdosWHERE{?personwdt:P485wd:Q964035.?personwdt:P18?image.?personwdt:P2021?ErdosSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! ChemistryChemical elements and their propertiesSELECT?elementLabel?_boiling_point?_melting_point?_electronegativity?_density?_massWHERE{?elementwdt:P31wd:Q11344.?elementwdt:P2102?_boiling_point.?elementwdt:P2101?_melting_point.?elementwdt:P1108?_electronegativity.?elementwdt:P2054?_density.?elementwdt:P2067?_mass.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}LIMIT100 Try it! Chemical elements and their isotopes by number of neutrons (min/max)SELECT?element(SAMPLE(?symbol)AS?symbol)(SAMPLE(?protons)AS?protons)(MIN(?neutrons)AS?minNeutrons)(MAX(?neutrons)AS?maxNeutrons)WHERE{?elementwdt:P31wd:Q11344;wdt:P1086?protons;wdt:P246?symbol.?isotopewdt:P279?element;wdt:P1148?neutrons.}GROUP BY?elementORDER BY?protons Try it! Colors of chemical compounds#defaultView:BubbleChartSELECT?rgb?colorLabel(COUNT(?compound)AS?count)WHERE{?compoundwdt:P31wd:Q11173;wdt:P462?color.OPTIONAL{?colorwdt:P465?rgb.}BIND(IF(BOUND(?rgb),?rgb,"CCCCCC")AS?rgb).SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?rgb?colorLabel Try it! All pKa data in Wikidata and the source titlesSELECT?compound?compoundLabel?pKa?source?sourceLabel?doiWHERE{?compoundwdt:P31wd:Q11173;p:P1117?statement.?statementrdf:typewikibase:BestRank;ps:P1117?pKa.OPTIONAL{?statementprov:wasDerivedFrom/pr:P248?source.OPTIONAL{?sourcewdt:P356?doi.}}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}#English label} Try it! All CAS registry numbers in WikidataSELECTDISTINCT?compound?compoundLabel?casWHERE{?compoundwdt:P231?cas.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Chemical compounds in Wikidata sharing the same CAS registry number#two chemical compounds with the same CAS registry numberSELECTDISTINCT?cas?compound1?compound1Label?compound2?compound2LabelWHERE{?compound1wdt:P231?cas.?compound2wdt:P231?cas.FILTER(?compound1!=?compound2)SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! The number of Chemical compounds in Wikidata sharing the same CAS registry number#The number of times a cas registry number is shared by distinct Wikidata itemsSELECT?cas?itemsWHERE{{SELECTDISTINCT?cas(count(?compound)as?items)WHERE{?compoundwdt:P231?cas.}GROUP BY?cas}FILTER(?items>1)}ORDER BYdesc(?items) Try it! Awarded Chemistry Nobel Prizes#defaultView:TimelineSELECTDISTINCT?item?itemLabel?when(YEAR(?when)as?date)?picWHERE{?itemp:P166?awardStat.# … with an awarded(P166) statement?awardStatps:P166wd:Q44585.# … that has the value Nobel Prize in Chemistry (Q35637)?awardStatpq:P585?when.# when did they receive the Nobel prizeSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}OPTIONAL{?itemwdt:P18?pic}} Try it! Images of organic acids#defaultView:ImageGridSELECT?compound?compoundLabel?imageWHERE{?compoundwdt:P279+|wdt:P31+wd:Q421948;wdt:P18|wdt:P117?image.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Boiling points of alkanesSELECTDISTINCT?comp?compLabel?formula?bp?bpUnit?bpUnitLabelWHERE{?compwdt:P31/wdt:P279*wd:Q41581;wdt:P274?formula;p:P2102[ps:P2102?bp;psv:P2102/wikibase:quantityUnit?bpUnit].SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYDESC(?bpUnit)ASC(?bp) Try it! Solubilities of chemicalsSELECTDISTINCT?chemical?chemicalLabel?value?units?unitsLabel?solvent?solventLabel?temperature?temperatureUnit?temperatureUnitLabel?source?sourceLabel?doiWITH{SELECTDISTINCT?chemical?value?units?source?doi?solvent?temperature?temperatureUnitWHERE{?chemical?propp?statement.?statementawikibase:BestRank;?proppsv[wikibase:quantityAmount?value;wikibase:quantityUnit?units].OPTIONAL{?statementprov:wasDerivedFrom/pr:P248?source.OPTIONAL{?sourcewdt:P356?doi.}}?propertywikibase:claim?propp;wikibase:statementValue?proppsv;wdt:P1629wd:Q170731;wdt:P31wd:Q21077852.OPTIONAL{?statementpqv:P2076?temperatureNode.?temperatureNodewikibase:quantityAmount?temperature;wikibase:quantityUnit?temperatureUnit.}OPTIONAL{wd:P2178wikibase:qualifier?qualifierS.?qualifierSaowl:ObjectProperty.?statement?qualifierS?solvent.}}GROUP BY?chemical?value?units?temperature?temperatureUnit?solvent?source?doi}AS%resultWHERE{INCLUDE%resultSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYASC(?propEntityLabel) Try it! SpaceWho discovered the most asteroids?SELECT?discoverer?name(COUNT(?asteroid)AS?count)WHERE{?asteroidwdt:P31wd:Q3863.?asteroidwdt:P61?discoverer.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?discovererrdfs:label?name}}GROUP BY?discoverer?nameORDER BYDESC(?count)LIMIT20 Try it! Who discovered the most planets? (with list)SELECT?discoverer?discovererLabel(COUNT(DISTINCT?planet)as?count)(GROUP_CONCAT(DISTINCT(?planetLabel);separator=", ")as?planets)WHERE{?ppartwdt:P279*wd:Q634.?planetwdt:P31?ppart.?planetwdt:P61?discoverer.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".?discovererrdfs:label?discovererLabel.?planetrdfs:label?planetLabel}}GROUP BY?discoverer?discovererLabelORDER BYDESC(?count) Try it! List of space probes with pictures#defaultView:ImageGridSELECT?spaceProbeLabel?date?pictureWHERE{?spaceProbewdt:P31wd:Q26529;wdt:P18?picture;wdt:P619?date.#mandatorySERVICEwikibase:label{bd:serviceParamwikibase:language"fr,en".}}ORDER BY?dateLIMIT88 Try it! Birthplaces of astronauts# select all astronauts with name, image, birthdate, birthplace and coordinates of the birthplaceSELECT?astronaut?astronautLabel?image?birthdate?birthplace?coordWHERE{?astronaut?x1wd:Q11631;wdt:P18?image;wdt:P569?birthdate;wdt:P19?birthplace.?birthplacewdt:P625?coordSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?birthdate) Try it! (Artist) Images of Exoplanets#defaultView:ImageGridSELECT?exoplanet?exoplanetLabel?imageWHERE{?exoplanetwdt:P31wd:Q44559;wdt:P18?image.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! ScientistsNumber of scientists per genderItems used: human (Q5) , scientist (Q901) Properties used: sex or gender (P21) , instance of (P31) , occupation (P106) , subclass of (P279) SELECT?gender(count(distinct?human)as?number)WHERE{?humanwdt:P31wd:Q5;wdt:P21?gender;wdt:P106/wdt:P279*wd:Q901.}GROUP BY?genderLIMIT10 Try it! Most eponymous mathematiciansItems used: mathematician (Q170790) Properties used: named after (P138) occupation (P106) SELECT?eponym?eponymLabel?count?sample?sampleLabelWHERE{{SELECT?eponym(COUNT(?item)as?count)(SAMPLE(?item)AS?sample)WHERE{?itemwdt:P138?eponym.?eponymwdt:P106wd:Q170790.}GROUP BY?eponym}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BYDESC(?count) Try it! Authors of scientific articles by occupation#defaultView:BubbleChartSELECT?occupationLabel(count(DISTINCT?author)as?count)WHERE{?objectwdt:P31wd:Q13442814;wdt:P50?author.?authorwdt:P106?occupation.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,fr"}}GROUP BY?occupationLabelORDER BYDESC(?count) Try it! Authors of scientific articles who received a Nobel prize#added in 2016-10#Authors of scientific articles who received a Nobel prizeSELECT?item?itemLabel?person?personLabel?_image?award?awardLabelWHERE{?personwdt:P166?award;#person received an awardwdt:P31wd:Q5.#person is instance of human?awardwdt:P31/wdt:P279*wd:Q7191.#award is a Nobel Prize?itemwdt:P50?person;#person is an author of itemwdt:P31wd:Q13442814.#item is a scientific articleSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}OPTIONAL{?personwdt:P18?_image.}#Wikimedia Commons has an image of person} Try it! Using VALUES for extracting scientific articles of specific authorsItems used: Lydia Pintscher (Q18016466) scholarly article (Q13442814) Properties used: instance of (P31) author (P50) SELECT?entity?entityLabel?authorLabelWHERE{VALUES?author{wd:Q18016466}#initialize "?author with the Wikidata item "Lydia Pintscher" ?entitywdt:P31wd:Q13442814.#filter by scientific articles?entitywdt:P50?author.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Female scientists with most number of sitelinks (but not English Wikipedia)#Female scientists with most number of sitelinks (but not English Wikipedia)#PREFIX schema: <http://schema.org/>SELECT?item?itemLabel?linkcountWHERE{?itemwdt:P31wd:Q5.?itemwdt:P21wd:Q6581072.?itemwdt:P106wd:Q901.?itemwikibase:sitelinks?linkcount.FILTER(?linkcount>=1).# only include items with 1 or more sitelinksFILTERNOT EXISTS{?articleschema:about?item.?articleschema:inLanguage"en".?articleschema:isPartOf<https://en.wikipedia.org/>}SERVICEwikibase:label{bd:serviceParamwikibase:language"en,de,es,ar,fr"}}GROUP BY?item?itemLabel?linkcountORDER BYDESC(?linkcount) } SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,es,ar,fr" } } GROUP BY ?item ?itemLabel ?linkcount ORDER BY DESC(?linkcount)<]<)+}"> Try it! Inventors killed by their own inventionSELECT?inventor?inventorLabel?gadget?gadgetLabelWHERE{?inventorwdt:P157?gadget.?gadgetwdt:P61?inventor.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Most cited female authors#added 2016-12##defaultView:BubbleChartSELECT?author?authorLabel(COUNT(?publication)AS?count)WHERE{?itemwdt:P2860?publication.#citations?publicationwdt:P50?author.#authors?authorwdt:P21wd:Q6581072.#femalesSERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?author?authorLabelORDER BYDESC(?count) Try it! Scientists who have worked together but whose Erdos numbers don’t reflect that# Finds authors who have published scientific articles together,# but whose Erdos numbers are more than one apart.# These would appear to violate the definition of the Erdos number.SELECT# Q#s?paper?author1?author2# title (either from title statement or label)(IF(BOUND(?title),?title,?paperLabel)AS?title)# author labels (should be names) and their Erdos numbers?author1Label?erdos1?author2Label?erdos2# distance between Erdos numbers?distanceWHERE{# paper, instance of or subclass of scientific article; also has two authors?paperwdt:P31/wdt:P279*wd:Q13442814;wdt:P50?author1,?author2.# if it has a title, we’ll grab that as well, but it’s also okay if there’s no titleOPTIONAL{?paperwdt:P1476?title.}# grab Erdos numbers of the two authors?author1wdt:P2021?erdos1.?author2wdt:P2021?erdos2.# introduce a new variable for the difference of the Erdos numbersBIND(?erdos2-?erdos1AS?distance).# select those cases where the distance is > 1# (note: by *not* taking the absolute value of the distance, we avoid getting duplicated cases because the author variables might be swapped)FILTER(?distance>1).# get *Label variables automagicallySERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}# sort by distance first (descending), then by first author, then by second authorORDER BYDESC(?distance)?author1Label?author2Label Try it! Map of institutions where Canadian citizens got their PhD Map of institutions where Canadian citizens got their PhD - screenshot of the query results as of 2018-08-01.#defaultView:MapSELECTDISTINCT?institution?institutionLabel?academics?academicsLabel?degree?degreeLabel?geoloc?imageWHERE{?academicswdt:P31wd:Q5;# instances (P31) of humans (Q5)wdt:P27wd:Q16;# country of citizenshipp:P69?statement.# check for an "educated at" (P69) statementOPTIONAL{?academicswdt:P18?image}.#image?statementps:P69?institution.# get value of the "educated at" statement, i.e. the institution?institutionwdt:P625?geoloc.# get the geolocation of the institution?statementpq:P512?degree.# get qualifier "academic degree" (P512) ?degreewdt:P31/wdt:P279*wd:Q849697.# filter for doctoral degreesSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Scientific literaturePMID-DOI mappingsSELECTDISTINCT?pmid?doiWHERE{?itemwdt:P698?pmid;wdt:P356?doi.} Try it! The number of statements by DOISELECT?doi(COUNT(?entry)as?entries){?entry?p?statement.?statementprov:wasDerivedFrom/pr:P248/wdt:P356?doi.}GROUP BY?doiORDER BYDESC(?entries) Try it! number of statements backed by a reference with a DOISELECT(COUNT(?statement)as?statements)WHERE{?entry?p?statement.?statementprov:wasDerivedFrom/<http://www.wikidata.org/prop/reference/P248>/wdt:P356?doi.} Try it! Statements originating from a specific DOISELECT?entryRes?entry?statementWHERE{?entryRes?p?statement;rdfs:label?entry.?statementprov:wasDerivedFrom/<http://www.wikidata.org/prop/reference/P248>/wdt:P356"10.1021/JA01577A030".FILTER(lang(?entry)="en")} Try it! Translations of the Disease Ontology term DOID:399 (Tuberculosis)Properties used: Disease Ontology ID (P699) Wikimedia language code (P424) SELECT?English?language?labelWHERE{?diseasewdt:P699"DOID:399";rdfs:label?English;rdfs:label?label.BIND(LANG(?label)as?languageCode)?wdLanguagewdt:P424?languageCode;rdfs:label?language.FILTEREXISTS{?wdLanguagewdt:P31?/wdt:P279+wd:Q17376908}FILTER(LANG(?English)="en")FILTER(LANG(?language)="en")}ORDER BY?language Try it! Library and Information Science journalsitems used: scientific journal (Q5633421) library science (Q199655) library science (Q199655) information science (Q16387) library and information science (Q13420675) Properties used: instance of (P31) main subject (P921) SELECTDISTINCT?journal?nameWHERE{?journalwdt:P31wd:Q5633421.# is scientific journal{{?journalwdt:P921wd:Q199655}# with topic library scienceUNION{?journalwdt:P921wd:Q16387}# and/or topic information scienceUNION{?journalwdt:P921wd:Q13420675}# and/or topic library and information science }SERVICEwikibase:label{bd:serviceParamwikibase:language"en".?journalrdfs:label?name.}} Try it! Most popular subjects of scientific articlesselect(count(?work)as?count)?subject?subjectLabelwhere{?workwdt:P31wd:Q13442814;wdt:P921?subject.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}group by?subject?subjectLabelorder bydesc(?count)limit200 Try it! Scientific journals with editors on TwitterSELECT?journal?journalLabel?editor?editorLabel?twitter?ex_publisher?ex_publisherLabelWITH{SELECT?journal?editor?twitter(SAMPLE(?publisher)AS?ex_publisher)WHERE{?journalwdt:P31wd:Q5633421;wdt:P98?editor.OPTIONAL{?journalwdt:P123?publisher}?editorwdt:P2002?twitter.}GROUP BY?journal?editor?twitter}AS%resultWHERE{INCLUDE%resultSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?journalLabel Try it! MathMathematical proofsSELECT?proof?proofLabelWHERE{?proofwdt:P31wd:Q11538.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Timeline of death of mathematicans and their theorems#defaultView:TimelineSELECT?genderLabel?theorem?theoremLabel?nameLabel?death?formulaWHERE{SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,de,pl".}?theoremwdt:P31wd:Q65943;wdt:P138?name.?namewdt:P570?death;wdt:P21?gender.# OPTIONAL{?theoremwdt:P2534?formula.# }}ORDER BYDESC(?death)LIMIT100 Try it! Databases listed in Wikidata and if available applicable licensesSELECTDISTINCT*WHERE{?itemwdt:P31wd:Q8513;rdfs:label?name.OPTIONAL{?itemwdt:P275?licenseItem.?licenseItemrdfs:label?license.FILTER(LANG(?license)="en")}FILTER(LANG(?name)="en")} Try it! Fictional universes with most fictional planetsSELECT?universe(SAMPLE(?label)AS?label)(COUNT(?planet)AS?count)WHERE{?planetwdt:P31wd:Q2775969;wdt:P1080?universe.?universerdfs:label?label.FILTER(LANG(?label)="en").}GROUP BY?universeORDER BYDESC(?count) Try it! Objects with most mass

The following query uses these:

Items: unit of mass (Q3647172)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , mass (P2067)    View with Reasonator   View with SQID SELECT?object?objectLabel?massWHERE{{SELECT?object(MAX(?mass)AS?mass)WHERE{?objectp:P2067/psn:P2067/wikibase:quantityAmount?mass.MINUS{?objectwdt:P31wd:Q3647172.}}GROUP BY?objectORDER BYDESC(?mass)LIMIT100}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?mass) Try it! Biological databases listed in Wikidata and, if available, applicable licensesSELECT?item?itemLabel?url?licence?licenceLabelWHERE{?itemwdt:P31wd:Q4117139.OPTIONAL{?itemwdt:P856?url}OPTIONAL{?itemwdt:P275?licence}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BY?itemLabel Try it! American universities founded before the states they reside in were createdItems used: university (Q3918) . state of the United States (Q35657) Properties used: instance of (P31) , subclass of (P279) , inception (P571) , located in the administrative territorial entity (P131) ,SELECT?uLabel?founded?stateLabel?stateStartWHERE{?uwdt:P31/wdt:P279*wd:Q3918;wdt:P131+?state;wdt:P571?founded.?statewdt:P31wd:Q35657;wdt:P571?stateStart.FILTER(?founded<?stateStart).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}LIMIT10 Try it! Universities ranked by PageRank on English Wikipedia (federated query)Items used: university (Q3918) Properties used: instance of (P31) , subclass of (P279) PREFIXvrank:<http://purl.org/voc/vrank#>SELECTDISTINCT?uni?uniLabel?prWHERE{?uniwdt:P31/wdt:P279*wd:Q3918.SERVICE<http://dbpedia.org/sparql>{?univrank:hasRank/vrank:rankValue?pr}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYDESC(?pr)LIMIT50 Try it! HistoryPresidents and spouses#TEMPLATE={"template":"Presidents of ?country and their spouses","variables":{"?country":{"query":" SELECT ?id WHERE { ?id wdt:P31 wd:Q6256 . }"} } }SELECT?p?pLabel?ppicture?w?wLabel?wpictureWHERE{BIND(wd:Q30AS?country)?country(p:P6/ps:P6)?p.?pwdt:P26?w.OPTIONAL{?pwdt:P18?ppicture.?wwdt:P18?wpicture.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! US presidents & causes of deathList of presidents with causes of deathItems used: President of the United States (Q11696) Properties used: position held (P39) , cause of death (P509) SELECT?h?hLabel?cause?causeLabel(YEAR(?date)AS?year)WHERE{?hwdt:P39wd:Q11696;wdt:P509?cause;wdt:P570?dateSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?year Try it! Presidents and their causes of death ranking#defaultView:BubbleChartSELECT?cid?cause(count(*)as?count)WHERE{?pidwdt:P39wd:Q11696.?pidwdt:P509?cid.OPTIONAL{?cidrdfs:label?causefilter(lang(?cause)="en").}}GROUP BY?cid?causeORDER BYDESC(?count)ASC(?cause) Try it! Politicians who died of cancer (of any type)Items used: politician (Q82955) , cancer (Q12078) Properties used: occupation (P106) , subclass of (P279) , cause of death (P509) SELECT?politician?cause?politician_label?cause_of_death_labelWHERE{?politicianwdt:P106wd:Q82955.# find items that have "occupation (P106): politician (Q82955)"?politicianwdt:P509?cause.# with a P509 (cause of death) claim?causewdt:P279*wd:Q12078.# ... where the cause is a subclass of (P279*) cancer (Q12078)# ?politician wdt:P39 wd:Q11696 . # Uncomment this line to include only U.S. PresidentsOPTIONAL{?politicianrdfs:label?politician_labelfilter(lang(?politician_label)="en").}OPTIONAL{?causerdfs:label?cause_of_death_labelfilter(lang(?cause_of_death_label)="en").}}ORDER BYASC(?politician) Try it! List of popesItems used: pope (Q19546) Q50 Properties used: date of birth (P569) instance of (P31) image (P18) date of death (P570) SELECT?link?linkLabel?picture?ageWHERE{?linkwdt:P31wd:Q5;p:P39[ps:P39wd:Q19546;pq:P580?startTime].OPTIONAL{?linkwdt:P569?dateOfBirth}OPTIONAL{?linkwdt:P18?picture}OPTIONAL{?linkwdt:P570?dateOfDeath}BIND(YEAR(?dateOfDeath)-YEAR(?dateOfBirth)as?age)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],fr,en"}}ORDER BYDESC(?startTime) Try it! Years with 3 popesItems used: pope (Q19546) Properties used: position held (P39) start time (P580) end time (P582) replaces (P1365) replaced by (P1366) SELECT?year?pope1Label?pope2Label?pope3LabelWHERE{?pope2p:P39[ps:P39wd:Q19546;pq:P580?p2s;pq:P582?p2e;pq:P1365?pope1;pq:P1366?pope3].?pope1p:P39[ps:P39wd:Q19546;pq:P582?p1e].?pope3p:P39[ps:P39wd:Q19546;pq:P580?p3s].BIND(YEAR(?p2s)AS?year).FILTER(YEAR(?p2e)=?year&&YEAR(?p1e)=?year&&YEAR(?p3s)=?year).SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?year Try it! Popes with childrenItems used: human (Q5) pope (Q19546) Properties used: father (P22) position held (P39) image (P18) # All popes with number of childrenSELECT(SAMPLE(?father)as?father)?fatherLabel(SAMPLE(?picture)as?picture)(COUNT(?father)as?children)WHERE{?subjwdt:P22?father.?fatherwdt:P31wd:Q5.?fatherwdt:P39wd:Q19546.OPTIONAL{?fatherwdt:P18?picture.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}GROUP BY?fatherLabelORDER BYDESC(?children)LIMIT50 Try it! French heads of government by length of serviceItems used: human (Q5) head of government of France (Q15135541) Properties used: instance of (P31) position held (P39) image (P18) start time (P580) end time (P582) SELECTDISTINCT?item?itemLabel?positionLabel?picture?start?end?daysWHERE{?itemwdt:P31wd:Q5;p:P39?position_statement.?position_statementps:P39?position;pq:P580?startFILTER(?start>="1815-01-01T00:00:00Z"^^xsd:dateTime).?positionwdt:P279*wd:Q15135541.OPTIONAL{?position_statementpq:P582?x}OPTIONAL{?itemwdt:P18?picture}bind(if(bound(?x),?x,NOW())as?end)bind(floor(?end-?start)as?days)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYDESC(?days)?itemLabel Try it! List of countries in 1754Items used: sovereign state (Q3624078) historical country (Q3024240) sovereign state (Q3624078) Properties used: instance of (P31) , inception (P571) , dissolved, abolished or demolished date (P576) #updated 2020-12-06SELECTDISTINCT?h?hLabel?inception?dissolved?coorWHERE{VALUES?countryclass{wd:Q3024240wd:Q6256wd:Q3624078}?hp:P31/ps:P31?countryclass.?hwdt:P571?inception.OPTIONAL{?hwdt:P576?dissolved}.FILTER(?inception<"1755-01-01T00:00:00Z"^^xsd:dateTime)FILTER(?dissolved>="1755-01-01T00:00:00Z"^^xsd:dateTime||!Bound(?dissolved))SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}OPTIONAL{?hwdt:P625?coor}.}ORDER BY?inception= "1755-01-01T00:00:00Z"^^xsd:dateTime || !Bound(?dissolved) ) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } OPTIONAL { ?h wdt:P625 ?coor } . } ORDER BY ?inception<]<)+}"> Try it! Population in Europe after 1960Items used: European Union (Q458) Properties used: population (P1082) contains administrative territorial entity (P150) point in time (P585) SELECT?objectLabel(YEAR(?date)as?year)?population(?objectLabelas?Location)WHERE{wd:Q458wdt:P150?object.# European Union contains administrative territorial entity?objectp:P1082?populationStatement.?populationStatementps:P1082?population;pq:P585?date.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}FILTER(YEAR(?date)>=1960)}ORDER BY?objectLabel?year= 1960) } ORDER BY ?objectLabel ?year<]<)+}"> Try it! Locations of air accidentsItems used: aviation accident (Q744913) Properties used: instance of (P31) coordinate location (P625) SELECT?label?coord?placeWHERE{?subjwdt:P31wd:Q744913.?subjwdt:P625?coord.?subjrdfs:label?labelfilter(lang(?label)="en")} Try it! Most prolific fathersProperties used: father (P22) image (P18) SELECT?father?fatherLabel(SAMPLE(?picture_)AS?picture)?childrenWITH{SELECT?father(COUNT(?father)AS?children)WHERE{?subjwdt:P22?father.}GROUP BY?fatherORDER BYDESC(?children)LIMIT50}AS%get_fathersWHERE{INCLUDE%get_fathersOPTIONAL{?fatherwdt:P18?picture_.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}GROUP BY?father?fatherLabel?childrenORDER BYDESC(?children) Try it! List of suicide attacksSELECT?h?hLabel?location(CONCAT("injured: ",str(?injured))as?injuredl)(concat("dead: ",str(?dead))as?deadl)?date?imageWHERE{?hwdt:P31?attack.values(?attack){(wd:Q18493502)(wd:Q217327)}optional{?hwdt:P1339?injured.}optional{?hwdt:P1120?dead.}optional{?hwdt:P276?/wdt:P625?location}optional{?hwdt:P585?date}optional{?hwdt:P18?image}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! People who died by burning - on a timeline#defaultView:TimelineSELECT?person?personLabel?dateWHERE{?personwdt:P31wd:Q5;wdt:P509wd:Q468455;wdt:P570?date.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?date Try it! People who lived in the same period as another personselect?person?personLabel?personDescription?birth?death?age{?personwdt:P31wd:Q5.# instance of human?personwdt:P569?birth.# birth date?personwdt:P570?death.# death datehint:Priorhint:rangeSafetrue.# tell the optimizer that fields doesn’t mix dates, strings, integers or other data types, which simplifies the range comparisonfilter(?birth>"1452-04-15"^^xsd:dateTime&&?death<"1519-05-02"^^xsd:dateTime)# And between these two datesbind(year(?death)-year(?birth)as?age)# Make a new variable called ?age that we can usefilter(?age>10&&?age<100)# Only find people with realistic ages servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}# used to display a label} 10 && ?age < 100) # Only find people with realistic ages service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # used to display a label }<]<)+}"> Try it! People elevated in the public domain in 2020 "life+50 years"#added before 2019-02#Shows people raised in the public domain "life + 50 years".SELECT?item?itemLabel?genderLabel(GROUP_CONCAT(DISTINCT?occupationLabel;SEPARATOR=", ")AS?occupations)(GROUP_CONCAT(DISTINCT?countryLabel;SEPARATOR=", ")AS?countries)?death?articles{VALUES?target_country{wd:Q16wd:Q142wd:Q39wd:Q31wd:Q30}.#countries: Canada, France, Switzerland, Belgium, USA. Removing this line to get worldwide may cause a query timeout.VALUES?occ{wd:Q2500638wd:Q20826540wd:Q215627}.#occupation: creator, erudite, person. These 3 occupations will also look for subclasses. Example: Alan Turing is a cryptographer, a subclass of cryptologist, a subclass of mathematician, a subclass of scientist, a subclass of erudite.?itemwdt:P31wd:Q5;wdt:P21?gender;wdt:P27?target_country;wdt:P27?country;wdt:P106/wdt:P279*?occ;wdt:P106?occupation;wikibase:sitelinks?articles.#Service to count the number of articles in Wikipedia language versions. The higher the number, the greater the chances that the person is very notorious.?itemwdt:P570?death.hint:Priorhint:rangeSafetrue.FILTER(?death>="1969-01-01T00:00:00"^^xsd:dateTime&&?death<"1970-01-01T00:00:00"^^xsd:dateTime)#death: public domain "life+50 years". Change both years to get a list in different legislation. Example for USA: life+70 yearsSERVICEwikibase:label{bd:serviceParamwikibase:language"fr,en".#Service to retrieve the labels of items, in order of language. Example: if the label does not exist in French, the service will take the English label?itemrdfs:label?itemLabel.?genderrdfs:label?genderLabel.?occupationrdfs:label?occupationLabel.?countryrdfs:label?countryLabel.}.}GROUP BY?item?itemLabel?genderLabel?death?articlesORDER BYDESC(?articles)#Order by the number of articles in Wikipedia language versions. The most notorious people will be at the top of the list.= "1969-01-01T00:00:00"^^xsd:dateTime && ?death < "1970-01-01T00:00:00"^^xsd:dateTime ) #death: public domain "life+50 years". Change both years to get a list in different legislation. Example for USA: life+70 years SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" . #Service to retrieve the labels of items, in order of language. Example: if the label does not exist in French, the service will take the English label ?item rdfs:label ?itemLabel . ?gender rdfs:label ?genderLabel . ?occupation rdfs:label ?occupationLabel . ?country rdfs:label ?countryLabel . } . } GROUP BY ?item ?itemLabel ?genderLabel ?death ?articles ORDER BY DESC (?articles) #Order by the number of articles in Wikipedia language versions. The most notorious people will be at the top of the list.<]<)+}"> Try it! List of torture devicesSELECT?thing?thingLabel?imageWHERE{?thingwdt:P366wd:Q132781.?thingwdt:P18?image.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Animals that were executedSELECT?animal?animalLabel?died?mannerOfDeathLabel?imageWHERE{?animalwdt:P31/wdt:P31wd:Q16521;# instance of some taxon (does not include human)wdt:P509?mannerOfDeath.?mannerOfDeathwdt:P279*wd:Q8454.# some subclass of capital punishmentOPTIONAL{?animalwdt:P570?died.}OPTIONAL{?animalwdt:P18?image.}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BY?died Try it! People who were stateless for some time# persons who were stateless (country of citizenship: no value) for some time (start time and end time qualifiers)SELECT?person?personLabel?start?endWHERE{?personwdt:P31wd:Q5;p:P27[rdf:typewdno:P27;pq:P580?start;pq:P582?end].SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}ORDER BYDESC(?end-?start) Try it! Poets who were through An Lushan Rebellion# Poets who were through An Lushan RebellionSELECT?poet?poetLabelWHERE{SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],zh-hant,zh".}wd:Q253774wdt:P580?battleStartTime.wd:Q253774wdt:P582?battleEndTime.?poetwdt:P106wd:Q49757.?poetwdt:P497?cbdbId.?poetwdt:P569?birthDate.FILTER(?birthDate<?battleStartTime).?poetwdt:P570?deathDate.FILTER(?deathDate>?battleEndTime).} ?battleEndTime). }<]<)+}"> Try it! Periods of Japanese history and what they were named afterSELECT?era?eraLabel(YEAR(?start_time)AS?start)(YEAR(?end_time)AS?end)?namedLabel?namedDescriptionWHERE{?erawdt:P31wd:Q11514315;wdt:P361wd:Q130436;# eras of the history of Japanwdt:P580?start_time.MINUS{?erawdt:P2348/wdt:P361wd:Q130436}# exclude sub-erasOPTIONAL{?erawdt:P582?end_time}# optional end-time to make sure we include the current eraOPTIONAL{?erawdt:P138?named}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BY?startDESC(?end) Try it! Ancestors of Willem-Alexander of the NetherlandsSELECTDISTINCT?item?itemLabel?dateofbirthWHERE{wd:Q154952(wdt:P22|wdt:P25)*?item.OPTIONAL{?itemwdt:P569?dateofbirth}.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}ORDER BY?itemLabel Try it! CultureChurchesCathedrals in ParisItems used: cathedral (Q2977) Paris (Q90) Properties used: located in the administrative territorial entity (P131) instance of (P31) coordinate location (P625) image (P18) SELECT?item?itemLabel?placeLabel?coords?imageWHERE{?itemwdt:P31wd:Q2977.?itemwdt:P131?place.?placewdt:P131wd:Q90.OPTIONAL{?itemwdt:P625?coords.}OPTIONAL{?itemwdt:P18?image.}SERVICEwikibase:label{bd:serviceParamwikibase:language"fr".}}ORDER BY?placeLabel?itemLabel Try it! Churches in church district Wittenberg#defaultView:Map{"layer": "?pbLabel"}SELECT?item?itemLabel?pbLabel(SAMPLE(?cat)AS?cat)(SAMPLE(?coord)AS?coord)(SAMPLE(?img)AS?img)WHERE{wd:Q75849591wdt:P527[wdt:P527?item;wdt:P361?pb].?pbwdt:P31wd:Q76598130.?itemwdt:P625?coord.OPTIONAL{?itemwdt:P373?cat.}OPTIONAL{?itemwdt:P18?img.}SERVICEwikibase:label{bd:serviceParamwikibase:language"de".}}GROUP BY?item?itemLabel?pbLabel Try it! MuseumsMuseums in BrittanySELECTDISTINCT?museumLabel?museumDescription?villeId?villeIdLabel(?villeIdLabelAS?ville)?coord?lat?lonWHERE{?museumwdt:P539?museofile.# french museofile Id?museumwdt:P131*wd:Q12130.# in Brittany?museumwdt:P131?villeId.#city of the museum# ?object wdt:P166 wd:Q2275045 # that have french label "musées de France"OPTIONAL{?museumwdt:P856?link.}# official websiteOPTIONAL{?museumwdt:P625?coord.}# geographic coordOPTIONAL{?museump:P625?statement.?statementpsv:P625?node.?nodewikibase:geoLatitude?lat.?nodewikibase:geoLongitude?lon.}SERVICEwikibase:label{bd:serviceParamwikibase:language"fr".}#french label}ORDER BY?villeIdLabel Try it! All museums in Barcelona with coordinates#All museums (including subclass of museum) in Barcelona with coordinatesSELECTDISTINCT?item?name?coord?lat?lonWHERE{hint:Queryhint:optimizer"None".?itemwdt:P131*wd:Q1492.?itemwdt:P31/wdt:P279*wd:Q33506.?itemwdt:P625?coord.?itemp:P625?coordinate.?coordinatepsv:P625?coordinate_node.?coordinate_nodewikibase:geoLatitude?lat.?coordinate_nodewikibase:geoLongitude?lon.SERVICEwikibase:label{bd:serviceParamwikibase:language"ca".?itemrdfs:label?name}}ORDER BYASC(?name) Try it! Museums in Antwerp#defaultView:MapSELECT?item?itemLabel?coordinatesWHERE{?itemwdt:P31/wdt:P279*wd:Q33506;wdt:P131wd:Q12892;wdt:P625?coordinates.SERVICEwikibase:label{bd:serviceParamwikibase:language"nl, en"}} Try it! Louvre artworks in display cases#defaultView:ImageGridSELECT?item?itemLabel?itemDescription?imageWHERE{#part1: objects in cases{?itemwdt:P276?case.?casewdt:P31wd:Q3561331.?casewdt:P276?room.?roomwdt:P31/wdt:P279*wd:Q180516.# wd:Q15206795?roomwdt:P466?dep.?depwdt:P361+wd:Q19675}OPTIONAL{?itemwdt:P18?image}# Optionally with an imageSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,fr"}} Try it! Performing artsCharacters portrayed by most actorsSELECT?character?characterLabel(COUNT(?actor)AS?count)WHERE{{SELECTDISTINCT?character?actorWHERE{?filmp:P161[ps:P161?actor;pq:P453?character].#?character wdt:P31 wd:Q5. # uncomment to filter for real people}}SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}GROUP BY?character?characterLabelORDER BYDESC(?count)LIMIT25 Try it! List of theatre playsSELECT?play?playLabelWHERE{?playwdt:P31wd:Q25379.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,es,pt,de,fr,ja,zh".}}LIMIT1000 Try it! List of actors with pictures with year of birth and/or death#defaultView:ImageGridSELECT?human?humanLabel?yob?yod?pictureWHERE{?humanwdt:P31wd:Q5;wdt:P106wd:Q33999.?humanwdt:P18?picture.OPTIONAL{?humanwdt:P569?dob.?humanwdt:P570?dod}.BIND(YEAR(?dob)as?yob).#if available: yearBIND(YEAR(?dod)as?yod).SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}LIMIT88 Try it! Actors who played the same role more than 40 years apartSELECTDISTINCT?actor?actorLabel?characterLabel?movie1Label?movie2LabelWHERE{?movie1p:P161[ps:P161?actor;pq:P453?character];wdt:P577?movie1Publication.?movie2p:P161[ps:P161?actor;pq:P453?character];wdt:P577?movie2Publication.MINUS{?movie1wdt:P31/wdt:P279?wd:Q24856}# Not a seriesMINUS{?movie2wdt:P31/wdt:P279?wd:Q24856}# Not a seriesFILTER(?character!=wd:Q18086706).# Not as "themselves"FILTER(?movie1Publication+"P40Y"^^xsd:duration<?movie2Publication)# 40 years between themSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! LiteratureAuthors, writers and poets ranked by sitelink and also includes "country of citizenship"Items used: writer (Q36180) author (Q482980) poet (Q49757) Properties used: occupation (P106) country of citizenship (P27) SELECTdistinct?writer?place?linkcountWHERE{{?swdt:P106wd:Q36180.}UNION{?swdt:P106wd:Q482980.}UNION{?swdt:P106wd:Q49757.}?swdt:P27?pl.?swikibase:sitelinks?linkcount.OPTIONAL{?srdfs:label?writerfilter(lang(?writer)="en").}OPTIONAL{?plrdfs:label?placefilter(lang(?place)="en").}}GROUP BY?place?writer?linkcountHAVING(?linkcount>10)ORDER BYDESC(?linkcount) 10) ORDER BY DESC(?linkcount)<]<)+}"> Try it! Birth places of German poets#defaultView:Map{"hide": ["?coord"]}SELECT?subj?subjLabel?place?placeLabel?coord?birthyearWHERE{?subjwdt:P106wd:Q49757.?subjwdt:P19?place.?placewdt:P17wd:Q183.?placewdt:P625?coord.OPTIONAL{?subjwdt:P569?dob}BIND(YEAR(?dob)as?birthyear)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}} Try it! Books or literary works published before 1830 with place of publication or narrative location coordinatesItems used: book (Q571) literary work (Q7725634) Properties used: instance of (P31) publication date (P577) place of publication (P291) narrative location (P840) coordinate location (P625) SELECT?item?label?coord?placeWHERE{VALUES?type{wd:Q571wd:Q7725634}# book or literary work?itemwdt:P31?type.?itemwdt:P577?dateFILTER(?date<"1830-01-01T00:00:00Z"^^xsd:dateTime).?itemrdfs:label?labelfilter(lang(?label)="en")OPTIONAL{?item(wdt:P291|wdt:P840)?place.# publication or narration place is ?place?placewdt:P625?coord}} Try it! Books by a given Author including genres and year of first publicationSELECTdistinct?book?bookLabel?authorLabel(GROUP_CONCAT(?genre_label)as?genres)(MIN(?publicationDate)as?firstPublication)WHERE{?authorrdfs:label"Ernest Hemingway"@en.?bookwdt:P50?author.OPTIONAL{?bookwdt:P136?genre.?genrerdfs:label?genre_labelfilter(lang(?genre_label)="en").}OPTIONAL{?bookwdt:P577?publicationDate.}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}group by?book?bookLabel?authorLabel Try it! Text by author containing case-insensitive title with optional cover imageselectdistinct?item?authorLabel?itemLabel?imagewhere{?itemwdt:P31/wdt:P279*wd:Q234460.?author?label'Bram Stoker'.?itemwdt:P50?author.?itemrdfs:label?itemLabel.filtercontains(lcase(?itemLabel),'dracula').optional{?itemwdt:P18?image.}servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE]".}}limit50 Try it! Literary works by label countItems used: literary work (Q7725634) Properties used: instance of (P31) SELECT?s?desc(COUNT(DISTINCT?label)as?labelcount)WHERE{?swdt:P31wd:Q7725634.?srdfs:label?label.OPTIONAL{?srdfs:label?descfilter(lang(?desc)="en").}}GROUP BY?s?descORDER BYDESC(?labelcount) Try it! All subclasses of "Literary Work"SELECT?s?descWHERE{?swdt:P279wd:Q7725634.OPTIONAL{?srdfs:label?descfilter(lang(?desc)="en").}} Try it! Epic poems by label countSELECT?s?desc(COUNT(DISTINCT?label)as?labelcount)WHERE{?swdt:P31wd:Q37484.?srdfs:label?label.OPTIONAL{?srdfs:label?descfilter(lang(?desc)="en").}}GROUP BY?s?descORDER BYDESC(?labelcount) Try it! Epic poems by sitelink count#old method for sitelink countSELECT?s?desc?linkcountWHERE{?swdt:P31wd:Q37484.?swikibase:sitelinks?linkcount.OPTIONAL{?srdfs:label?descfilter(lang(?desc)="en").}}GROUP BY?s?desc?linkcountORDER BYDESC(?linkcount) Try it! Instance of Book by sitelink count#old method for sitelink countSELECT?s?desc?linkcountWHERE{?swdt:P31wd:Q571.?swikibase:sitelinks?linkcount.OPTIONAL{?srdfs:label?descfilter(lang(?desc)="en").}}GROUP BY?s?desc?linkcountORDER BYDESC(?linkcount) Try it! Poets and monarchsItems used: Poet Laureate of the United Kingdom (Q877838) Properties used: position held (P39) start time (P580) appointed by (P748) end time (P582) date of birth (P569) date of death (P570) image (P18) SELECT?poetLabel?image?yob?yod?start?end?monarchLabelWHERE{?poetp:P39?positionStat.?positionStatps:P39wd:Q877838;pq:P580?start;pq:P748?monarch.OPTIONAL{?positionStatpq:P582?end.}OPTIONAL{?poetwdt:P18?image;wdt:P569?dob;wdt:P570?dod.}BIND(YEAR(?dob)AS?yob).BIND(YEAR(?dod)AS?yod).SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?startDESC(?monarchLabel) Try it! List of digital libraries in the worldSELECTDISTINCT?item?itemLabel?websiteWHERE{?itemwdt:P31/wdt:P279*wd:Q212805# digital libraries or subtypesOPTIONAL{?itemwdt:P856?website}# Official URL if knownMINUS{?itemwdt:P576[]}# Exclude those that have shut downSERVICEwikibase:label{bd:serviceParamwikibase:language"en, es, ca, fr, de, pl, uk, ru, he"}}ORDER BY?itemLabel Try it! Map of Libraries in Canada# Canadian libraries on a map (must have coordinates!)#defaultView:MapSELECT?library?libraryLabel?coordsWHERE{SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,fr".}?library(wdt:P31/wdt:P279*)wd:Q7075.?librarywdt:P17wd:Q16.?librarywdt:P625?coords.} Try it! List of authors unsuccessfully nominated for Nobel prize in literatureItems used: Nobel Prize in Literature (Q37922) Properties used: nominated for (P1411) , award received (P166) SELECT?nominee?nomineeLabel(SAMPLE(?citizenshipLabel)AS?country)(COUNT(DISTINCT?year)as?timesNominated)WHERE{BIND(wd:Q37922as?prize)?nomineep:P1411[ps:P1411?prize;pq:P585?time]BIND(year(?time)as?year)OPTIONAL{?nomineewdt:P27[rdfs:label?citizenshipLabel]filter(lang(?citizenshipLabel)="en").}FILTERNOT EXISTS{?nomineewdt:P166?prize.}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?nominee?nomineeLabelORDER BYDESC(?timesNominated)?nomineeLabel Try it! Authors whose works enter the public domain in 2017 (died in 1946)SELECTDISTINCT?itemWHERE{?itemwdt:P31wd:Q5;wdt:P106/wdt:P279*wd:Q482980.?itemwdt:P570?time0.FILTER((?time0>="1945-01-01T00:00:00Z"^^xsd:dateTime)&&(?time0<="1946-01-01T00:00:00Z"^^xsd:dateTime))} Try it! Authors with United States citizenship without a Goodreads identifier#authors with country of citizenship United States who do not have a Goodreads identifierSELECT?item?itemLabelWHERE{?itemwdt:P31wd:Q5.#instance of (P31) human (Q5)?itemwdt:P27wd:Q30.#country of citizenship (P27) is United States (Q30) ?itemwdt:P106wd:Q36180.#occupation (P106) is writer (Q36180)MINUS{?itemwdt:P2963[]}.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! All events that occured on 2001/09/11SELECT?item?itemLabelWHERE{?itemp:P585/ps:P585"2001-09-11T00:00:00Z"^^xsd:dateTimeSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Works by women that were born between 1800 and 1900, are in the WomenWriters database and are translatedselect?translator?translatorLabel?work?workLabel?author?authorLabel{?workwdt:P655?translator;wdt:P50?author.?authorwdt:P2533?wid;wdt:P21wd:Q6581072;wdt:P569?birth;filter(?birth>"1800-01-01"^^xsd:dateTime&&?birth<"1900-01-01"^^xsd:dateTime)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,nl,fr".}} Try it! MusicTimeline of albums by Manu Chao and Mano Negra#defaultView:TimelineSELECT?album?performerLabel?albumLabel?publication_dateWHERE{VALUES?performer{wd:Q936474wd:Q207898}?albumwdt:P175?performer;wdt:P577?publication_date.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Most popular tonalitySELECT?tonalityLabel(COUNT(?tonalityLabel)as?count)WHERE{?workwdt:P826?tonality.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?tonalityLabelORDER BYDESC(?count) Try it! Music composers by birth place#defaultView:MapSELECT?item?itemLabel?_coordinates?_imageWHERE{?itemwdt:P106wd:Q36834;# occupation: composerwdt:P18?_image;# with an image depicting themwdt:P19/wdt:P625?_coordinates# their birthplace, specifically the coordinates of their birthplaceSERVICEwikibase:label{bd:serviceParamwikibase:language"en"}# labels in English} Try it! Composers and their most-used tonalityProperties used: composer (P86) tonality (P826) # Each composer’s most used tonality, with number of works in that tonality.# (If this is ambiguous – multiple tonalities with the same number – there are multiple results for one composer.)## The SPARQL for this is an evil perversion of three subqueries (one of them nested in another).# To understand it, you have to go inside out… follow the numbers.SELECT?composerLabel?tonalityLabel?countWHERE{{# 4. Group again, this time just by the composer.# We also select the highest count of a tonality.# Notice that we don’t know what tonality this count is associated with – we’ll get to that.# So now we have each composer, along with how often they used whatever tonality they used most.SELECT?composer(MAX(?count)AS?count)WHERE{{# 2. Group by composer and tonality, so that for each composer and tonality, we get a count of how often the composer used this tonality.SELECT?composer?tonality(COUNT(?composition)AS?count)WHERE{# 1. Extremely straightforward: the ?composition has the composer ?composer and the tonality ?tonality.# (I’m not bothering with any “instance of” because the presence of these two properties is a sufficient indicator of ?composition being a composition.)?compositionwdt:P86?composer;wdt:P826?tonality.}GROUP BY?composer?tonalityHAVING(?count>1)# 3. Limit that to counts > 1, because using a tonality once is hardly “most used”.}}GROUP BY?composer}{# 6. Identical to 2.SELECT?composer?tonality(COUNT(?composition)AS?count)WHERE{# 5. Identical to 1.?compositionwdt:P86?composer;wdt:P826?tonality.}GROUP BY?composer?tonalityHAVING(?count>1)# 7. Identical to 3.}# 8. That’s it. Wait, what?# From 4, we now have ?composer, any composer, and ?count, the count of how often they used whatever tonality they used most.# From 6, we also have a ?composer, as well as a ?tonality, and the count of how often they used that particular tonality.# The trick is that ?composer and ?count are the same variable in each subquery, and so now, when the two subqueries are joined,# we select only that ?tonality from 6 where the ?composer and the ?count are identical to those from 4 –# that is, where this tonality was used as often as the composer’s most-used tonality.# In other words, this must *be* the composer’s most-used tonality (except when there are multiple tonalities with the same count).SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(?count)# 9. Order by count (highest first), because the result isn’t very meaningful for low counts (many compositions aren’t on Wikidata or don’t have a tonality statement). Try it! Songs with longest melodyProperties used: Parsons code (P1236) SELECT?song?songLabel?codeWHERE{?songwdt:P1236?code.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BYDESC(STRLEN(REPLACE(?code," ","")))LIMIT10 Try it! How many musicians dies at certain ageItems used: human (Q5) musician (Q639669) Properties used: instance of (P31) occupation (P106) subclass of (P279) date of birth (P569) date of death (P570) # Query to find all musicians who have already died# calculate their age (full years) at death# count how many of them died at each ageSELECT?age(COUNT(DISTINCT?a)AS?count)WHERE{?awdt:P31wd:Q5.#instance of human?awdt:P106/wdt:P279wd:Q639669.#occupation a subclass of musician?ap:P569/psv:P569?birth_date_node.?ap:P570/psv:P570?death_date_node.?birth_date_nodewikibase:timeValue?birth_date.?death_date_nodewikibase:timeValue?death_date.FILTER(?age>10&&?age<100).#ignore outlyers, several of which are probably errorsBIND(year(?death_date)-year(?birth_date)-if(month(?death_date)<month(?birth_date)||(month(?death_date)=month(?birth_date)&&day(?death_date)<day(?birth_date)),1,0)as?age)# calculate the age, precisely to the day (times and timezones ignored)}GROUP BY?ageORDER BY?age Try it! Musicians born in Rotterdam (the Netherlands)Items used: Rotterdam (Q34370) musician (Q639669) Properties used: instance of (P31) occupation (P106) subclass of (P279) place of birth (P19) selectdistinct?item?itemLabel?itemDescriptionwhere{?itemwdt:P106/wdt:P279*wd:Q639669.?itemwdt:P19/wdt:P131*wd:Q34370.SERVICEwikibase:label{bd:serviceParamwikibase:language"en,nl"}} Try it! Paintings depicting woodwind instruments Paintings depicting woodwind instrumentsItems used: painting (Q3305213) woodwind instrument (Q181247) Properties used: instance of (P31) subclass of (P279) depicts (P180) image (P18) # added in 2017-06#defaultView:ImageGridSELECT?item?itemLabel?object?objectLabel?imageWHERE{?itemwdt:P31/wdt:P279*wd:Q3305213.?itemwdt:P180?object.?objectwdt:P279*wd:Q181247.?itemwdt:P18?image.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Paintings depicting musical instruments with some connection to HamburgItems used: painting (Q3305213) musical instrument (Q34379) Hamburg (Q1055) Properties used: instance of (P31) subclass of (P279) depicts (P180) image (P18) #defaultView:ImageGridSELECTDISTINCT?item?image{hint:Queryhint:optimizer"None".?objectwdt:P279*wd:Q34379.?itemwdt:P180?object.?itemwdt:P31/wdt:P279*wd:Q3305213.?itemwdt:P18?image.?item?prop?hhlink.?hhlink?prop2wd:Q1055.} Try it! Visual artsPublic sculptures in ParisSELECTDISTINCT?item?Titre?createur(year(?date)as?AnneeCreation)?image?coordWHERE{?itemwdt:P31/wdt:P279*wd:Q860861.# sculpture?itemwdt:P136wd:Q557141.# genre : art public{?itemwdt:P131wd:Q90.}# ... située dans ParisUNION{?itemwdt:P131?arr.# ... ou dans un arrondissement de Paris ?arrwdt:P131wd:Q90.}?itemrdfs:label?Titrefilter(lang(?Titre)="fr").# TitreOPTIONAL{?itemwdt:P170?Qcreateur.# créateur/créatrice (option)?Qcreateurrdfs:label?createurfilter(lang(?createur)="fr").}OPTIONAL{?itemwdt:P571?date.}# date de création (option)OPTIONAL{?itemwdt:P18?image.}# image (option)OPTIONAL{?itemwdt:P625?coord.}# coordonnées géographiques (option)} Try it! Locations of Pablo Picasso works#defaultView:MapSELECT?label?coord?subjWHERE{?subjwdt:P170wd:Q5593.OPTIONAL{?subjwdt:P276?loc.?locwdt:P625?coord}.?subjrdfs:label?labelfilter(lang(?label)="en")} Try it! Eiffel Tower in artSELECTDISTINCT?item?itemLabel?instanceLabel?creatorLabel(YEAR(?date)as?year)?imageWHERE{?itemwdt:P180wd:Q243.?itemwdt:P31?instance.OPTIONAL{?itemwdt:P170?creator}OPTIONAL{?itemwdt:P571?date}OPTIONAL{?itemwdt:P18?image}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?itemLabel Try it! Paintings by Gustav Klimt#defaultView:ImageGridSELECT*WHERE{?itemwdt:P31wd:Q3305213.?itemwdt:P170wd:Q34661.?itemwdt:P18?pic.} Try it! Map of all the paintings for which we know a location with the count per location#Map of all the paintings for which we know a location with the count per location#defaultView:MapSELECT?locationLabel?coord(count(*)as?count)WHERE{?paintingwdt:P31wd:Q3305213.?paintingwdt:P276?location.?locationwdt:P625?coordSERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?locationLabel?coord Try it! Versions of The ScreamSELECT?item(SAMPLE(?itemL)AS?title)(SAMPLE(?y)AS?year)(SAMPLE(?typeL)AS?type)(group_concat(distinct?materialL;separator=", ")as?materials)(SAMPLE(?collectionL)AS?collection)(SAMPLE(?img)AS?image){SELECT?item?itemL(YEAR(?date)AS?y)?typeL?collectionL?img?materialLWHERE{?itemwdt:P179wd:Q471379.?itemwdt:P18?img.?itemwdt:P571?date.?itemwdt:P31?instance.?itemrdfs:label?itemLfilter(lang(?itemL)="en").?instancerdfs:label?typeLfilter(lang(?typeL)="en").OPTIONAL{?itemwdt:P195?collection.?collectionrdfs:label?collectionLfilter(lang(?collectionL)="en").}OPTIONAL{?itemwdt:P186?material.?materialrdfs:label?materialLfilter(lang(?materialL)="en").}}}GROUP BY?itemORDER BY?year?item?itemLabel Try it! Depicted objects in art workSELECTDISTINCT?depicts(SAMPLE(?dL)AS?depictsLabel)(COUNT(DISTINCT?item)AS?count)WHERE{?itemwdt:P180?depicts.OPTIONAL{?depictsrdfs:label?dLfilter(lang(?dL)="en")}}GROUP BY?depictsORDER BYDESC(?count)?depictsLabel Try it! Monuments historiques in Loire-AtlantiqueSELECTDISTINCT?item?itemLabel?communeLabel(group_concat(distinct?merimee;separator=", ")as?merimee)?coords?imageWHERE{{SELECTDISTINCT?item?merimeeWHERE{?itemwdt:P1435/wdt:P279*wd:Q916475.?itemp:P1435?heritage_statement.FILTERNOT EXISTS{?heritage_statementpq:P582?end.}?itemwdt:P380?merimee.}ORDER BY?merimee}?itemwdt:P131/wdt:P131*wd:Q3068.?itemwdt:P131?commune.OPTIONAL{?itemwdt:P625?coords.}OPTIONAL{?itemwdt:P18?image.}SERVICEwikibase:label{bd:serviceParamwikibase:language"fr".}}GROUP BY?item?itemLabel?communeLabel?coords?imageORDER BY?communeLabel?itemLabel Try it! Sculptures by Max BillSELECTDISTINCT?item?itemLabel?countryLabel?placeLabel(YEAR(?date)as?year)?coords?imageWHERE{?itemwdt:P31/wdt:P279*wd:Q860861.?itemwdt:P170wd:Q123454.OPTIONAL{?itemwdt:P17?country.}OPTIONAL{?itemwdt:P131?place.}OPTIONAL{?itemwdt:P571?date.}OPTIONAL{?itemwdt:P625?coords.}OPTIONAL{?itemwdt:P18?image.}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?itemLabel?placeLabel Try it! Paintings by Rembrandt in the Louvre or the Rijkmuseum#defaultView:ImageGridSELECTDISTINCT?item?itemLabel?itemDescription?image?collectionWHERE{?itemwdt:P31wd:Q3305213;# Get items that are instances of paintingwdt:P170wd:Q5598;# By creator Rembrandtwdt:P195/wdt:P361*?collection.# That are in some collection# Only return results where 'collection' is either Rijkmuseum or LouvreFILTER(?collection=wd:Q190804||?collection=wd:Q19675)OPTIONAL{?itemwdt:P18?image}# Optionally with an imageSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE]"}} Try it! Authority control properties usage for paintings# Make a list of the most used authority control properties for works for paintingsSELECT?propertyLabel?propertyDescription(COUNT(?propertyclaim)AS?count)WHERE{?itemwdt:P31wd:Q3305213.?propertywikibase:propertyTypewikibase:ExternalId.?propertywdt:P31wd:Q44847669.?propertywikibase:claim?propertyclaim.?item?propertyclaim[].SERVICEwikibase:label{# ... include the labelsbd:serviceParamwikibase:language"en".}}GROUP BY?propertyLabel?propertyDescriptionORDER BYDESC(?count)LIMIT100 Try it! Authority control properties usage for painters# Make a list of the most used authority control properties for people for paintersSELECT?propertyLabel?propertyDescription?countWHERE{{select?propertyclaim(COUNT(*)AS?count)where{?itemwdt:P106wd:Q1028181.?itemwdt:P31wd:Q5.?item?propertyclaim[].}group by?propertyclaim}?propertywikibase:propertyTypewikibase:ExternalId.?propertywdt:P31wd:Q19595382.?propertywikibase:claim?propertyclaim.SERVICEwikibase:label{# ... include the labelsbd:serviceParamwikibase:language"en".}}ORDER BYDESC(?count)LIMIT100 Try it! Ten random painting images# This returns 10 random painting images# RAND() returns one random number (cached like every query).# The string representation of the item and the random number are hashed.# This will give a complete different ordering every time you have a different random number.# You can change the LIMIT if you want to trigger a new random number#defaultView:ImageGridSELECT?item?itemLabel?image(MD5(CONCAT(str(?item),str(RAND())))as?random)WHERE{?itemwdt:P31wd:Q3305213.?itemwdt:P18?image.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}ORDER BY?randomLIMIT10 Try it! Painters related to anonymous works#Paintings by anonymous painters, but are related to some other painter#defaultView:BubbleChartSELECT?creatorqualifierLabel(COUNT(?creatorqualifier)AS?count)WHERE{?itemwdt:P31wd:Q3305213.?itemwdt:P170wd:Q4233718.OPTIONAL{?itemp:P170?creatorstatement.?creatorstatementrdf:typewikibase:BestRank.?creatorstatement?qualifier?creatorqualifier.?qualifierpropertywikibase:qualifier?qualifier}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?creatorqualifierLabelHAVING(?count>2)LIMIT20000 2) LIMIT 20000<]<)+}"> Try it! Painters type of relations with anonymous works#Paintings by anonymous painters, types of relationships with other painters#defaultView:BubbleChartSELECT?qualifierpropertyLabel(COUNT(?creatorqualifier)AS?count)WHERE{?itemwdt:P31wd:Q3305213.?itemwdt:P170wd:Q4233718.OPTIONAL{?itemp:P170?creatorstatement.?creatorstatementrdf:typewikibase:BestRank.?creatorstatement?qualifier?creatorqualifier.?qualifierpropertywikibase:qualifier?qualifier}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?qualifierpropertyLabelHAVING(?count>2)LIMIT2000 2) LIMIT 2000<]<)+}"> Try it! Using formatter url to construct links in SPARQL# Get 10 paintings that have a link to RKDimages (P350)# Use the formatter URL (P1630) to construct the links to RKDimages#defaultView:ImageGridSELECT?item?image?rkdurlWHERE{wd:P350wdt:P1630?formatterurl.?itemwdt:P31wd:Q3305213.?itemwdt:P18?image.?itemwdt:P350?rkdid.BIND(IRI(REPLACE(?rkdid,'^(.+)$',?formatterurl))AS?rkdurl).}LIMIT10 Try it! Map of the locations of all paintings by Johannes Vermeer with an image#defaultView:Mapselect?painting?paintingLabel?location?imagewhere{?paintingwdt:P276?collection;wdt:P170wd:Q41264;wdt:P18?image.?collectionwdt:P625?location.servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Public art in ParisSELECT?item(SAMPLE(?titleL)AS?title)(group_concat(distinct?creatorL;separator=", ")as?creator)(group_concat(distinct?genreL;separator=", ")as?genre)(group_concat(distinct?placeL;separator=", ")as?place)(group_concat(distinct?arr;separator=", ")as?arrondissement)(SAMPLE(?img)AS?image)(SAMPLE(?coord)AS?coordinates){{SELECTDISTINCT?item{{?itemwdt:P136wd:Q557141;# genre: public artwdt:P131wd:Q90# located in: Paris}UNION{# or?itemwdt:P136wd:Q557141;# genre: public artwdt:P131/wdt:P131*wd:Q90# located in an arrondissement of Paris}}}# titleOPTIONAL{?itemrdfs:label?titleLfilter(lang(?titleL)="fr")}# creatorsOPTIONAL{?itemwdt:P170[rdfs:label?creatorL]filter(lang(?creatorL)="fr")}#genreOPTIONAL{{?itemwdt:P136?gfilter(STR(?g)!='http://www.wikidata.org/entity/Q557141')}UNION{?itemwdt:P31?g.}?grdfs:label?genreLfilter(lang(?genreL)="fr").}# placeOPTIONAL{?itemwdt:P276[rdfs:label?placeL]filter(lang(?placeL)="fr").}# arrondissementOPTIONAL{?itemwdt:P131[wdt:P131wd:Q90;rdfs:label?arrL]filter(lang(?arrL)="fr").BIND(REPLACE(?arrL,'^([0-9]+).*$',"$1","si")AS?arr)}# imageOPTIONAL{?itemwdt:P18?img}# coordinatesOPTIONAL{?itemwdt:P625?coord}}GROUP BY?item Try it! Works of art where the name might be a rhymeSELECT?work?titleWHERE{?workwdt:P31/wdt:P279*wd:Q838948;wdt:P1476?title.FILTER(REGEX(?title,"^\\w*(\\w{3})(\\W+\\w*\\1)+$","i")&&!REGEX(?title,"^(\\w+)(\\W+\\1)+$","i")).}ORDER BYSTR(?title) Try it! Works of art where the title is an alliterationSELECT?work?titleWHERE{?workwdt:P31/wdt:P279*wd:Q838948;wdt:P1476?title.FILTER(REGEX(STR(?title),"^(\\p{L})\\w+(?:\\W+\\1\\w+){2,}$","i")).}ORDER BYSTR(?title) Try it! Distribution of public art by placeSELECT?place?placeLabel(COUNT(*)AS?count)WHERE{?itemwdt:P136wd:Q557141.?itemwdt:P131?place.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}GROUP BY?place?placeLabelORDER BYDESC(?count)?placeLabel Try it! Birthplaces of Europeana280 artists#defaultView:MapSELECT?creator?creatorLabel?placebirthLabel?geolocwhere{?itemwdt:P31/wdt:P279*wd:Q838948.# œuvre d’art et ss-classe?itemwdt:P608wd:Q20980830.# du projet Europeana 280?itemwdt:P170?creator.# créateur?creatorwdt:P19?placebirth.# lieu de naissance?placebirthwdt:P625?geoloc.#coordonnées géoSERVICEwikibase:label{bd:serviceParamwikibase:language"fr,es,en".}} Try it! Female artistsSELECTDISTINCT?women?womenLabelWHERE{?womenwdt:P31wd:Q5.?womenwdt:P21wd:Q6581072.?womenwdt:P106/wdt:P279*wd:Q483501.# artistsSERVICEwikibase:label{bd:serviceParamwikibase:language"fr,en"}}LIMIT500 Try it! Common phrasesItems used: Redewendung (Q15841920) Properties used: instance of (P31) SELECT?q?qLabelWHERE{?qwdt:P31wd:Q15841920.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Food & DrinkGerman breweries#Locations of breweries in Germany#defaultView:Mapselect?breweryLabel?breweryDescription?coordWHERE{?brewerywdt:P31/wdt:P279*wd:Q131734;wdt:P17wd:Q183;wdt:P625?coord.SERVICEwikibase:label{bd:serviceParamwikibase:language"en, de".}} Try it! Sandwiches#defaultView:ImageGridSELECT?item?itemLabel?_imageWHERE{?itemwdt:P279wd:Q28803.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}OPTIONAL{?itemwdt:P18?_image.}}LIMIT100 Try it! Sandwich ingredientsSELECT?sandwich?ingredient?sandwichLabel?ingredientLabelWHERE{?sandwichwdt:P31?/wdt:P279*wd:Q28803;wdt:P527?ingredient.MINUS{?ingredientwdt:P279*wd:Q7802.}SERVICEwikibase:label{bd:serviceParamwikibase:language"en","fr".}}ORDER BYUCASE(STR(?sandwichLabel)) Try it! SportsMushers with neither a ranking in a race nor a reason for not finishing itItems used: sled dog racing (Q1968664) Properties used: instance of (P31) , subclass of (P279) , sport (P641) , participant (P710) , ranking (P1352) , significant event (P793) SELECTdistinct?race?raceLabel?musherLabelWHERE{{?racewdt:P31/wdt:P279*wd:Q1968664.}UNION{?racewdt:P31/wdt:P641*wd:Q1968664.}?racep:P710?musherS.#here we have a full statement, not a value?musherSps:P710?musher.#here we get the valueFILTERNOT EXISTS{?musherSpq:P1352?rank}FILTERNOT EXISTS{?musherSpq:P793?event}SERVICEwikibase:label{bd:serviceParamwikibase:language"fr,en"}}ORDER BY?raceLabel Try it! What is the relation between Terrell Buckley and Miami Dolphins?Items used: Terrell Buckley (Q5571382) , Miami Dolphins (Q223243) SELECT?lWHERE{wd:Q5571382?pwd:Q223243.?property?ref?p.?propertyrdf:typewikibase:Property.?propertyrdfs:label?lFILTER(lang(?l)="en")} Try it! The awards received by Cristiano Ronaldo by year

Shows only the year instead of the default format (i.e. show all of the date information).

SELECT?entity?desc(year(?date)as?year){wd:Q11571p:P166[ps:P166?entity;pq:P585?date]OPTIONAL{?entityrdfs:label?descFILTER((LANG(?desc))="en")}}ORDER BY?year Try it! WomenWomen mushersItems used: human (Q5) musher (Q500097) female (Q6581072) Properties used: instance of (P31) occupation (P106) sex or gender (P21) selectdistinct?musher?musherLabelwhere{?musherwdt:P31wd:Q5.?musherwdt:P106wd:Q500097.?musherwdt:P21wd:Q6581072servicewikibase:label{bd:serviceParamwikibase:language"fr,en".}} Try it! Female brewerSELECT?item?itemLabel?itemDescriptionWHERE{?itemwdt:P31wd:Q5;wdt:P21wd:Q6581072;wdt:P106wd:Q836904.SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}ORDER BY?itemLabel Try it! Female scientists# Female scientistsSELECT?item?itemLabel?lastnameLabel?birthdate?deathdate?nationalityLabel?itemDescriptionWHERE{?itemwdt:P31wd:Q5.?itemwdt:P21wd:Q6581072.?itemwdt:P106/wdt:P279*wd:Q901.optional{?itemwdt:P734?lastname.}optional{?itemwdt:P569?birthdate.}optional{?itemwdt:P570?deathdate.}optional{?itemwdt:P27?nationality.}SERVICEwikibase:label{bd:serviceParamwikibase:language"nl,en,fr,de,es,it,no"}}order by?itemLabel Try it! Verify women descriptionsSELECT?item?itemLabel?occupationLabel?itemDescriptionWHERE{?itemwdt:P31wd:Q5.?itemwdt:P21wd:Q6581072.?itemwdt:P27wd:Q31.optional{?itemwdt:P106?occupation.}SERVICEwikibase:label{bd:serviceParamwikibase:language"nl".}} Try it!

If needed you can update inappropriate descriptions.

Tips:

export to Excel and sort by descriptiongenerate a QuickStatements fileStreets in France named after a womanSELECT?street?streetLabel?cityLabel?namedLabelWHERE{?streetwdt:P31wd:Q79007.?streetwdt:P17wd:Q142.?streetwdt:P131?city.?streetwdt:P138?named.?namedwdt:P21wd:Q6581072SERVICEwikibase:label{bd:serviceParamwikibase:language"fr"}}ORDER BY?city Try it! Queries for bibliographic citation (Wikicite)Figshare citationsWikidata statements with a reference to data in FigshareSELECT?doi(count(?doi)as?counts)WHERE{?statementprov:wasDerivedFrom?ref.?refpr:P356?doi.FILTER(CONTAINS(lcase(?doi),"figshare"))}GROUP BY?doiORDER BYDESC(?counts) Try it! Wikidata statement with a reference to data in Figshare of which a Wikicite item existsSELECTDISTINCT?wikiciteLabel?doiWHERE{?wikicitep:P356/ps:P356?doi.?statementprov:wasDerivedFrom?ref.?refpr:P356?doi.FILTER(CONTAINS(lcase(?doi),"figshare"))SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Wikidata statements with a reference to a Figshare DOI ( Q28061352 )SELECTDISTiNCT?item?itemLabelWHERE{?item?p?statement.?statementprov:wasDerivedFrom?ref.?ref?propwd:Q28061352.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}} Try it! Zika corpusScholarly articles with "Zika" in the item label

The following query uses these:

Items: scholarly article (Q13442814)    View with Reasonator   View with SQID Properties: instance of (P31)    View with Reasonator   View with SQID , PubMed ID (P698)    View with Reasonator   View with SQID SELECTDISTINCT?item?itemLabel?_PubMed_IDWHERE{?itemwdt:P31wd:Q13442814;rdfs:label?itemLabel.OPTIONAL{?itemwdt:P698?_PubMed_ID.}FILTER(CONTAINS(LCASE(?itemLabel),"zika"))FILTER(LANG(?itemLabel)="en")} Try it! Most common Zika authorSELECT?short_author?short_authorLabel(count(?item)as?count)WHERE{{?itemwdt:P921wd:Q202864.}UNION{?itemwdt:P921wd:Q8071861.}{?itemwdt:P2093?short_author.}UNION{?itemwdt:P50?short_author.}SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}}GROUP BY?short_author?short_authorLabelORDER BYDESC(?count) Try it! Scientific articles that have subject Zika virus or fever and that are used as a reference in another itemSELECT?item?itemLabel?reference?referenceTypeWHERE{?itemwdt:P31wd:Q13442814#Scientific article{?itemwdt:P921wd:Q202864}#Zika virusUNION{?itemwdt:P921wd:Q8071861}#Zika fever?reference?referenceType?item#find references to item having any property and store reference typeSERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! CIViC CorpusGet the CIViC citation corpusSELECTDISTINCT?pmid?citation?citationLabelWHERE{VALUES?predictor{p:P3354p:P3355p:P3356p:P3357p:P3358p:P3359}?itemp:P3329?civicId;?predictor?predictor_value.?civicIdps:P3329?id.?predictor_valueprov:wasDerivedFrom?reference.?referencepr:P248?citation.?citationwdt:P698?pmid;SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Biological pathway citation corporaGet the Pathways citation corpusSELECT?id?item?itemLabel?referenceLabelWHERE{{?itemwdt:P3937?id}UNION{?itemwdt:P2410?id}?itemwdt:P2860?reference.SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Get the Wikipathways citation corpusSELECT?wpid?item?itemLabel?referenceLabelWHERE{?itemwdt:P2410?wpid;wdt:P2860?reference;SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Get the Reactome citation corupsSELECT?reactome_id?item?itemLabel?referenceLabelWHERE{?itemwdt:P3937?reactome_id;wdt:P2860?reference;SERVICEwikibase:label{bd:serviceParamwikibase:language"en"}} Try it! Suriname citation corporaSELECT?item?itemLabel?_PubMed_IDWHERE{?itemwdt:P31wd:Q13442814;rdfs:label?itemLabel.FILTER(CONTAINS(LCASE(?itemLabel),"suriname"))OPTIONAL{?itemwdt:P698?_PubMed_ID.}} Try it! English common names and information for animals given their scientific names# Given the scientific name for a list of animals, it will return all the# English common names, their length, life expectency, height, wing span and mass# Note: There is more information on these specific animals. Unfortunately, a lot of animals on WikiData have missing information (e.g. no life expectancy or mass)SELECTDISTINCT?item?scientific_name?common_name?length?life_expectency?height?wing_span?massWHERE{?itemwdt:P225?scientific_name;wdt:P1843?common_name.OPTIONAL{?itemwdt:P2043?length.}OPTIONAL{?itemwdt:P2250?life_expectency.}OPTIONAL{?itemwdt:P2048?height.}OPTIONAL{?itemwdt:P2050?wing_span.}# Adult mass only. Excludes birth massOPTIONAL{?itemp:P2067?mass_statement_node.?mass_statement_nodepq:P642wd:Q78101716;ps:P2067?mass.}# Only return common names in EnglishFILTER(LANGMATCHES(LANG(?common_name),"en"))# List of animals. All lowercase to avoid capitalisation issuesFILTER(lcase(str(?scientific_name))IN("mustela erminea","aquila adalberti","vespula germanica","accipiter nisus","buteo buteo"))SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}} Try it! Mediawiki APIFilter labels using EntitySearch from mwapi service to provide Full Text Search

See documentation and examples in the MWAPI user manual.

#Combine the Wikidata Query Service and the Mediawiki API#https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#(which is backed by Elasticsearch) to perform very fast searching of entities by their label.##This query will first contact EntitySearch (an alias to wbsearchentities)#which will pass the items with a label of "soriano" it found to the triple store#which in turn can now query the graph in a timely manner and filter those entities that are not humans.#This solution only works if the number of items returned by wbsearchentities remains reasonable.SELECT?item?itemLabelWHERE{SERVICEwikibase:mwapi{bd:serviceParamwikibase:endpoint"www.wikidata.org";wikibase:api"EntitySearch";mwapi:search"soriano";# Search for things named "soriano"mwapi:language"en".?itemwikibase:apiOutputItemmwapi:item.}MINUS{?itemwdt:P31wd:Q5.# but MINUS or negate any of those things that are instances of human}SERVICEwikibase:label{bd:serviceParamwikibase:language"en".}}LIMIT100 Try it! Using mwapi to base a query on articles in a Wikipedia category# Use the MediaWiki API to get the articles from a specific category in a specific Wikipedia language version.# Then use this results as usual in a query, in this example a simple query for the gender.# By User:Ainali with the help of User:Dipsacus fullonum 2021-02SELECT?item?itemLabel?genderLabelWHERE{SERVICEwikibase:mwapi{bd:serviceParamwikibase:endpoint"sv.wikipedia.org";# Set the project herewikibase:api"Generator";mwapi:generator"categorymembers";# Selects the content from a categorymwapi:gcmtitle"Category:Födda 2001";.# Specifies the category (Born in 2001)?itemwikibase:apiOutputItemmwapi:item.}FILTERBOUND(?item)# Safeguard to not get a timeout from unbound items when using ?item below?itemwdt:P21?gender.# Example retrieval of a valueSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en,sv".}} Try it! Federation examplesGet OpenStreetMap top level properties of Helsinki University main building#Combine the Wikidata Query Service and the OpenStreetMap Sophox query servicePREFIXosmnode:<https://www.openstreetmap.org/node/>PREFIXosmway:<https://www.openstreetmap.org/way/>PREFIXosmrel:<https://www.openstreetmap.org/relation/>PREFIXosmt:<https://wiki.openstreetmap.org/wiki/Key:>PREFIXosmm:<https://www.openstreetmap.org/meta/>PREFIXpageviews:<https://dumps.wikimedia.org/other/pageviews/>PREFIXosmd:<http://wiki.openstreetmap.org/entity/>PREFIXosmdt:<http://wiki.openstreetmap.org/prop/direct/>PREFIXosmp:<http://wiki.openstreetmap.org/prop/>PREFIXosmps:<http://wiki.openstreetmap.org/prop/statement/>PREFIXosmpq:<http://wiki.openstreetmap.org/prop/qualifier/>SELECT*WHERE{BIND(wd:Q28695as?wd)SERVICE<https://sophox.org/sparql>{?osmidosmt:wikidata?wd;osmt:building?building;?a?b}} Try it! Get information of Europeana item using federated query#Get information of Europeana item using federated queryPREFIXdc:<http://purl.org/dc/elements/1.1/>PREFIXedm:<http://www.europeana.eu/schemas/edm/>PREFIXore:<http://www.openarchives.org/ore/terms/>SELECT*WHERE{BIND(<http://data.europeana.eu/proxy/provider/91622/raa_kmb_16000200042758>as?p854)SERVICE<http://sparql.europeana.eu/>{{?p854<http://purl.org/dc/terms/created>?created.?p854<http://purl.org/dc/elements/1.1/identifier>?identifier.?p854<http://purl.org/dc/elements/1.1/publisher>?publisher.?p854<http://purl.org/dc/elements/1.1/rights>?rights.?p854<http://purl.org/dc/elements/1.1/title>?title.?p854<http://purl.org/dc/elements/1.1/description>?description.}}} Try it! Share of renewable energy in electricity using Federated query#Get share of renewable energy in electricity using Federated query# Read share of renewable energy in electricity in EU countries from http://semantic.eea.europa.eu # and populate the result with finnish and inari sami labels from WikidataPREFIXcube:<http://purl.org/linked-data/cube#>PREFIXsdmx-measure:<http://purl.org/linked-data/sdmx/2009/measure#>PREFIXsdmx-dimension:<http://purl.org/linked-data/sdmx/2009/dimension#>PREFIXsdmx-attribute:<http://purl.org/linked-data/sdmx/2009/attribute#>PREFIXproperty:<http://rdfdata.eionet.europa.eu/eurostat/property#>SELECTDISTINCT(YEAR(?timePeriod)as?year)(?obsValueas?Share_of_renewable_energy_in_electricity)?unit_EN?unit_SMN?nuts?country_EN?country_SMN?flag?countryWITH{SELECT*WHERE{# Route query through zbw.eu as semantic.eea.europa.eu is not visible to query.wikidata.orgSERVICE<http://zbw.eu/beta/sparql/stw/query>{# Read share of renewable energy in electricity in EU countries from http://semantic.eea.europa.eu SERVICE<http://semantic.eea.europa.eu/sparql>{SELECT*WHERE{?rowcube:dataSet<http://rdfdata.eionet.europa.eu/eurostat/data/nrg_ind_335a>.?rowproperty:indic_en<http://dd.eionet.europa.eu/vocabulary/eurostat/indic_en/119820>.?rowsdmx-dimension:timePeriod?timePeriod.?rowsdmx-measure:obsValue?obsValue.?rowsdmx-attribute:unitMeasure?unitTmp.?rowsdmx-dimension:refArea?countryTmp.?countryTmpskos:prefLabel?country_EN.?countryTmpskos:notation?nuts.?unitTmprdfs:label?unit_EN.FILTER(YEAR(?timePeriod)=2016)}}}}}AS%semantic_eea_europa_euWHERE{INCLUDE%semantic_eea_europa_eu.# And populate the result with finnish and inari sami labels and flag from Wikidata?countrywdt:P605?nuts.?countrywdt:P41?flag.?unitwdt:P3328?unit_EN.OPTIONAL{?countryrdfs:label?country_FIFILTER(LANG(?country_FI)="fi")}.OPTIONAL{?countryrdfs:label?country_SMNFILTER(LANG(?country_SMN)="smn")}.OPTIONAL{?unitrdfs:label?unit_FIFILTER(LANG(?unit_FI)="fi")}.OPTIONAL{?unitrdfs:label?unit_SMNFILTER(LANG(?unit_SMN)="smn")}.FILTER(?countryNOT IN(wd:Q756617,wd:Q29999))# Filter out Kingdom Denmark and Kingdom of Netherlands}ORDER BYDESC(?Share_of_renewable_energy_in_electricity)LIMIT35# Expected number of results is 34 Try it! Retrieved from " https://www.wikidata.org/w/index.php?title=Wikidata:SPARQL_query_service/queries/examples&oldid=1371483668 " Categories : Wikidata:SPARQL query service Wikidata-en SPARQL Exploring Wikidata Navigation menuPersonal toolsNot logged in Talk Contributions Create account Log in Namespaces Project page Discussion VariantsViews Read View source View history MoreSearch
Navigation Main page Community portal Project chat Create a new Item Recent changes Random Item Query Service Nearby Help Donate Lexicographical data Create a new Lexeme Recent changes Random Lexeme Tools What links here Related changes Special pages Permanent link Page information Wikidata item Print/export Create a book Download as PDF Printable version In other projects Wikimedia Commons In Wikipedia Add links This page was last edited on 27 February 2021, at 14:24.All structured data from the main, Property, Lexeme, and EntitySchema namespaces is available under the Creative Commons CC0 License ; text in the other namespaces is available under the Creative Commons Attribution-ShareAlike License ; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Privacy policy About Wikidata Disclaimers Mobile view Data access Developers Statistics Cookie statement Wikimedia Foundation Powered by MediaWiki
© 2014-2021 ЯВИКС - все права защищены.
Наши контакты