Wikibase/Indexing/SPARQL Query Examples

Syntax according to ../RDF Dump Format/. See also 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: d: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 Dump Format/

Cats

 * Items used:

Horses

 * Items used:
 * Properties used:

Recent Events

 * Items used:
 * Properties used:

Popular eye colors

 * Items used: None
 * Properties used:

Even more cats, with pictures

 * Items used:
 * Features used:

People whom we know we don't know their gender

 * Items used:
 * Properties used: ,

Humans without children

 * Items used:
 * Properties 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:

Women with most sitelinks and no image born in 1921 or later

 * 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:

Airports in Belgium

 * 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:

Film directors ranked by number of sitelinks multiplied by their number of films

 * Items used:
 * Properties used:

The Simpsons television series episodes list by season

 * Items used:
 * Properties used:

Pokemon!

 * Items used:
 * Properties used:

Law & Order episodes

 * Items used:
 * Properties used:

Main subjects 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:

Countries sorted by population

 * Items used:
 * Properties used:

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:

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:

most frequent occupations without a label in a given language

 * Items used: None
 * Properties used:

Birthplaces of astronauts

 * Items used:
 * Properties used:

Sandwich ingredients

 * Items used:
 * Properties used: