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.

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

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

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

= Unsorted =

Even more cats

 * Items used:

US presidents and spouses

 * Items used:
 * Properties used: ,

US presidents & causes of death

 * Items used:
 * Properties used: ,

Politicians who died of cancer (of any type)

 * Items used: ,
 * Properties used:, ,

People born before year 1880 with no death date

 * Items used:
 * Properties used:, ,

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

List of present-day countries and capital(s)

 * Items used:
 * Properties used: ,

How many states this US state borders

 * Items used:
 * Properties used: ,

Whose birthday is today?

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

What is the relation between Terrell Buckley and Miami Dolphins?

 * Items used: ,

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

 * Items used:
 * Properties used:

Aliases of properties which are used more than once

 * Items used: none
 * Properties used: all

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

List of space probes with pictures

 * Items used:
 * Properties used: ,

List of parliament buildings with pictures by country

 * Items used:
 * Properties used:, ,

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

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

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

 * Items used: ,
 * Properties used: ,

Number of scientists per gender

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

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

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

Paintings by Gustav Klimt

 * Items used: ,
 * Properties used:, ,

Select French municipalities by INSEE code (select by identifier)

 * Properties used:

Statements from literature (DOI references)
Increasingly the Digital Object Identifier (DOI) is used to identifier literature, though not the only identifier. These example start with the DOI.

Most eponymous mathematicians

 * Uses

Airports within 100km of Berlin

 * Uses

Schools between San Jose, CA and Sacramento, CA

 * Uses

Longest rivers

 * Uses: ,

Popular names per birthplace

 * Uses: ,

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

 * Note:, , , ,

People born in Occitania for Listeria

 * Note:, , , ,

People born in Scotland for Listeria (1)

 * Note:, , ,

People born in Scotland for Listeria (2)

 * Note:, , ,