Wikibase/Indexing/SPARQL Query Examples

Syntax according to RDF Dump format. See also https://phabricator.wikimedia.org/T86786

Further examples can be found at d:Wikidata:SPARQL query service/queries

This page is parsed by the web interface of the query service to fill its drop down of example queries. Keywords in the line below the header are used to be populate the keyword cloud.

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.

WDQ queries: https://www.wikidata.org/wiki/Wikidata:List_of_queries

Standard Prefixes
These are standard prefixes, however their use is optional as the query endpoint knows to resolve standard prefixes automatically. PREFIX wd:  PREFIX wdt:  PREFIX wikibase:  PREFIX p:  PREFIX ps:  PREFIX pq:  PREFIX rdfs: 

Simple Queries
These queries help to understand SPARQL and the Wikibase RDF format

Cats

 * Items used:

popular eye colors

 * Items used: None
 * Properties used:

Even more cats, with pictures

 * Items used:
 * Features used:

Showcase Queries
These queries show the power and functionality of query.wikidata.org.

Largest cities with female mayor

 * Items used: ,
 * Properties used:, , , , ,

List of countries ordered by the number of their cities with female mayor

 * Items used: ,
 * Properties used:, , , , ,

popular surnames among humans

 * Items used:
 * Properties used:

given names with most variations

 * Items used:
 * Properties used:

popular surnames among fictional characters

 * Items used:
 * Properties used:

Overall causes of death ranking

 * Items used:
 * Properties used:
 * Features used:

WWII battle durations

 * Items used:
 * Properties used:
 * Features used:

Children of Genghis Khan

 * Items used:
 * Properties used:
 * Features used:

Music genres

 * Items used:
 * Properties used:
 * Features used:

Airports within 100km of Berlin

 * Items used:
 * Properties used:
 * Features used:

Schools between San Jose, CA and Sacramento, CA

 * Uses
 * Items used:
 * Properties used:
 * Features used:

Whose birthday is today?

 * Properties used:

Finding John and Sarah Connor

 * Items used:
 * Properties used:

Data of Douglas Adams

 * Items used:
 * Properties used:

Rock bands that start with "M"

 * Items used:
 * Properties used:

Winner of the Academy Awards by Award and Time

 * Items used:
 * Properties used:

Academy award data

 * items used:
 * Properties used:

Number of handed out academy awards per award type

 * Items used:
 * Properties used:

The Simpsons television series episodes list by season

 * Items used:
 * Properties used:

Law & Order episodes

 * Items used:
 * Properties used:

main subject of West Wing episodes

 * Items used:
 * Properties used:

movies with Bud Spencer

 * Items used:
 * Properties used:

Popular television series (in treeview)

 * Items used:
 * Properties used:
 * Features used:

Fictional subjects of the Marvel Universe

 * Items used:
 * Properties:

List of present-day countries and capital(s)

 * Items used:
 * Properties used: ,

Largest cities per country

 * Items used:
 * Properties used:

Wikidata people per million inhabitants for all EU countries

 * Items used:
 * Properties used:

Papers about wikidata

 * Items used:
 * Properties used:

Longest rivers

 * Items Used:
 * Properties used: ,
 * Features used:

body of water with the most watercourses ending in it

 * Items used: None
 * Properties used:

Mountains, with coordinates, not located on Earth

 * Items used:
 * Properties used:

highest mountains in the universe

 * Items used: None
 * Properties used:

Former capitals

 * Items used: None
 * Properties used:

map of braodway venues

 * Items used:
 * Properties used:

How many states this US state borders

 * Items used:
 * Properties used: ,

Continents

 * items used:
 * Properties used:

Some other continents

 * Items used: None
 * Properties used:

Places with continent Antarctica more than 3000 km north of south pole

 * Items used:
 * Properties used:

Places that are below 10 meters above sea level

 * Items used:
 * Properties used:

Largest cities of the world

 * Items used:
 * Properties used:
 * Features used:

Places within 1km of the Empire State Building

 * Items used:
 * Properties used:

Select French municipalities by INSEE code (select by identifier)

 * Properties used:

Emergency numbers by population using them

 * Items used :
 * Properties used:

German states, ordered by the number of company headquarters per million inhabitants

 * Items used:
 * Properties used:

Popular names per birthplace

 * Items used:
 * Properties used: ,
 * Features used:

Gender balance of members of Irish parliament

 * Items used:
 * Properties used:

Number of ministers who are themselves children of a minister, per country

 * Items used:
 * Properties used:

Databases listed in Wikidata and if available applicable licenses

 * Items used:
 * Properties used:

Fictional universes with most fictional planets

 * Items used:
 * Properties used:

inventors killed by their own invention

 * items used: None
 * Properties used:

objects with most mass

 * Items used:
 * Properties used:

Biological databases listed in Wikidata and if available applicable licenses

 * Items used:
 * Properties used:

The number of existing translations for diseases in Wikidata
Items used:

Who discovered the most asteroids?

 * Items used:
 * Properties used: ,

Who discovered the most planets? (with list)

 * Items used:
 * Properties used:, ,

American universities founded before the states they reside in were created

 * Items used:.
 * Properties used:, , , ,

Number of scientists per gender

 * Items used: ,
 * Properties used:, , ,

Most eponymous mathematicians

 * Items used:
 * Properties used:

Authors of scientific articles by occupation

 * Items used:
 * Properties used:
 * Features used:

Translations of the Disease Ontology term DOID:399 (Tuberculosis)

 * Items used:
 * Properties used:

US presidents and spouses

 * Items used:
 * Properties used: ,

List of presidents with causes of death

 * Items used:
 * Properties used: ,

Presidents and their causes of death ranking

 * Items used:
 * Properties used: ,
 * Features used:

Politicians who died of cancer (of any type)

 * Items used: ,
 * Properties used:, ,

List of popes

 * Items used:
 * Properties used:

popes with children

 * Items used:
 * Properties used:

years with 3 popes

 * Items used:
 * Properties used:

Popes with children

 * Items used:
 * Properties used:

French heads of government by length of service

 * Items used:
 * Properties used:

List of countries in 1754

 * Items used:
 * Properties used:, ,

Population in Europe after 1960

 * Items used:
 * Properties used:

Locations of air accidents

 * Items used:
 * Properties used:

Most prolific fathers

 * Properties used:

Find drugs for cancers that target genes related to cell proliferation
Items used:

Most common Zika author

 * Items used: ,
 * Properties used:

Wikidata scientific articles that contain "zika" in the title
Applicable Tags: ., ,

Scientific articles that have subject Zika virus or fever and that are used as a reference in another item

 * Items used:, ,
 * Properties used:

Parent taxons of Blue Whale

 * Items used:
 * Properties used:
 * Features used:

taxons and what they are named after

 * Items used: {Q|Q16521|taxon}}
 * Properties used:

Biologists with Twitter accounts

 * Items used:
 * Properties Used:

List of pharmaceutical drugs with picture

 * Items used:
 * Properties used:

Organisms that are located in the female urogential tract and that have a gene with product indole

 * Items used:
 * Properties used:

List of computer files formats

 * Items used:
 * properties used:

List of W3C standards

 * Items used:
 * Properties used:

Chemical elements and their properties

 * Items used:
 * Properties used:

chemical elements and their isotopes by number of neutrons (min/max)

 * Items used:
 * Properties used:

colors of chemical compounds

 * Items used:
 * Properties used:

Museums in Brittany
Tags:

cathedrals in Paris

 * Items used:
 * Properties used:

German breweries

 * Items used:
 * Properties used:

sculptures by Max Bill

 * Items used:
 * Properties used:

works of art where the name might be a rhyme

 * Items used:
 * Properties used:

works of art where the title is an alliteration

 * Items used:
 * Properties used:

Eiffel Tower in art

 * Items used:
 * Properties used:

birthplaces of Europeana280 artists

 * Items used:
 * Properties used:

Paintings by Gustav Klimt

 * Items used: ,
 * Properties used:, ,

Depicted objects in art work

 * Properties used:

Public sculptures in Paris

 * Items used:
 * Properties used:

Women who are artists

 * Items used:
 * Properties:

List of theatre plays

 * Items used:
 * Properties used:

Common phrases

 * Items used:
 * Properties used:

Authors, writers and poets ranked by sitelink and also includes "country of citizenship".

 * Items used:
 * Properties used:

Birthplaces of German Poets

 * Items used:
 * Properties used:

Books or literary works published before 1830 with place of publication or narrative location coordinates

 * Items used:
 * Properties used:

Books by a given Author including genres, series, and publication year

 * Items used:
 * Properties used:

Literary Works by Label Count

 * Items used:
 * Properties used:

All subclasses of "Literary Work"

 * Items used:
 * Properties used:

Epic Poems by Label Count

 * Items used:
 * Properties used:

Epic Poems by SiteLink Count

 * Items used:
 * Properties used:

Instance of Book by Sitelink Count

 * Items used:
 * Properties used:

Poets and monarchs

 * items used:
 * Properties used:

List of digital libraries in the world

 * Items used:
 * Properties used:

Most popular tonality

 * Properties used:

Music composers by birth place

 * Items used:
 * Properties used:

Composers and their most-used tonality

 * Items used: None
 * Properties used:

Mushers with neither a ranking in a race nor a reason for not finishing it

 * Items used:
 * Properties used:, , , , ,

What is the relation between Terrell Buckley and Miami Dolphins?

 * Items used: ,

Queries for maintenance
These queries help to maintain the data quality of Wikidata

Find duplicate IMDB identifiers

 * Properties used:

People born before year 1880 with no death date

 * Items used:
 * Properties used:, ,

Properties that are defined as "qualifier only" but are used in references

 * Items used:
 * Properties used:

Objects that have globe which does not match their coordinates

 * Properties used: ,

Aliases of properties which are used more than once

 * Items used: none
 * Properties used: all

Actresses without a description in Spanish

 * items used:
 * Properties used:

French people with an article on the English Wikipedia but not on the French one

 * Items used: ,
 * Properties used: ,

Deprecated rank statements
= Unsorted =

List of space probes with pictures

 * Items used:
 * Properties used: ,
 * Features used:

List of parliament buildings with pictures by country

 * Items used:
 * Properties used:, ,
 * Features used:

buildings in more than one country

 * Items used:
 * Properties used:

List of actors with pictures with year of birth and/or death

 * Items used: ,
 * Properties used:, , , ,
 * Features used:

files used as “image” in more than 10 items

 * Items used: None
 * Properties used:

Samples with coordinates to illustrate maps

 * Items used:
 * Properties used:

Locations of national parks

 * Features used:

places with free wifi

 * Items used: {Q|Q1543615|gratis}}
 * Properties used:

Map of U1 subway stations in Berlin

 * Items used:
 * Properties used:
 * Features used:

Locations of universities in Germany

 * Items used:
 * Properties used:
 * Features used:

Locations of power stations

 * Items used:
 * Properties used:
 * Features used:

Locations of stone arch bridges

 * Items used:
 * Properties Used:
 * Features used:

Locations of aqueducts

 * Items used:
 * Properties used:
 * Features used:

Locations of archaelogical sites

 * Items used:
 * Properties used:
 * Features used:

Locations of castles that are also archaeological sites

 * Items used:
 * Properties used:
 * Features used:

Locations of battles

 * Items used:
 * Properties used:
 * Features used:

Locations of Pablo Picasso works

 * Items used:
 * Properties used:
 * Features used:

All museums (including subclass of museum) in Washington, D.C. with coordinates

 * Items used:
 * Properties used:
 * Features used:

All ski resorts with coordinates

 * Items used:
 * Properties used:
 * Features used:

Lighthouses in Norway

 * Items used:
 * Properties used:
 * Features used:

List of torture devices

 * Items used:
 * Properties used:

number of jurisdictions by driving side

 * Items used: None
 * Properties used: {Q|P1622|driving side}}

average lifespan by occupation

 * Items used:
 * Properties used:

Items with the most birth dates

 * Properties used:

things/people with most children

 * Items used : None
 * Properties used:

people who died by burning - on a timeline

 * Items used:
 * Properties used:

French communes with names ending in ac

 * Items used:
 * Properties used:

Listeria
Samples suitable for Listeria. Generally only include ?item as output. Listeria will add more information from that item. Additional variables from the query could also be used in the lists.

Women born in Wales without an article in Welsh for Listeria

 * Items used:
 * Properties used:

People born in Occitania for Listeria

 * Items used:
 * Properties used:

People born in Scotland for Listeria (1)

 * Items used:
 * Properties used:

People born in Scotland for Listeria (2)

 * Items used:
 * Properties used: ,

Occupations with a German label

 * Items used:
 * Properties used:

Animals owned by people holding any position

 * Items used:
 * Properties used:

animals that were executed

 * Items used:
 * Properties used:

billionaires

 * Items used: None
 * Properties used:

birthplaces of astronauts

 * Items used:
 * Properties used:

sandwich ingredients

 * Items used:
 * Properties used: