Works set in San Francisco

SELECT ?work ?workLabel WHERE {
  ?work wdt:P840 wd:Q62 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}

Add 'apartment building (Q30316443)' as 'instance of'

  • Search for 'apartment building' items
  • careful to ignore 'field study'

National Register of Historic Places by US county and state

select ?county ?countyLabel ?stateLabel (count(*) as ?count) where {
  ?county wdt:P31/wdt:P279* ?county_of_state .
  ?county_of_state wdt:P279 wd:Q47168 .
  ?county_of_state wdt:P361* ?state .
  ?state wdt:P31 wd:Q35657 .
  ?item wdt:P649 ?nrhp .
  ?item wdt:P131 ?county .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} GROUP BY ?county ?countyLabel ?stateLabel

Mass shootings

SELECT ?item ?itemLabel ?isaLabel ?deaths ?date ?countryLabel
WHERE
{
  ?item wdt:P31/wdt:P279* wd:Q21480300 .
  ?item wdt:P31 ?isa
  optional { ?item wdt:P1120 ?deaths } .
  optional { ?item wdt:P585 ?date } .
  optional { ?item wdt:P17 ?country } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

fictional works

TV is a mess. There should be an item to represent a romantic comedy television series, currently there is only the film version. Same for crime drama. I added 'publication date' to a few TV series, but it feels wrong, because TV has a date range, start and finish. It should be possible to query for a TV series that hasn't finished, it is still being broadcast. Maybe TV series should use 'start date' and 'end date' instead of 'publication date'.

There are 52k that are an instance of television series. Of those 4k have a start time.

countries

Countries with ISO 3166 code and continent

SELECT ?iso3166 ?country ?countryLabel ?continentLabel WHERE {
    OPTIONAL { ?country wdt:P297 ?iso3166 }
    ?country wdt:P31 wd:Q3624078 . # sovereign state
    OPTIONAL { ?country wdt:P30 ?continent }
    FILTER NOT EXISTS {?country wdt:P31 wd:Q3024240}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
} ORDER BY ?iso3166 ?continentLabel ?countryLabel

Places with an ISO 3166 code tat aren't sovereign states.

SELECT ?iso3166 ?country ?countryLabel ?continentLabel WHERE {
    ?country wdt:P297 ?iso3166 .
    FILTER NOT EXISTS {?country wdt:P31 wd:Q3624078}
    OPTIONAL { ?country wdt:P30 ?continent }
    FILTER NOT EXISTS {?country wdt:P31 wd:Q3024240}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
} ORDER BY ?iso3166 ?continentLabel ?countryLabel

brewpubs and brewpub chains

SELECT ?item ?itemLabel ?type ?founded ?locationLabel ?countryLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  { ?item wdt:P31 wd:Q3640372 .BIND ("brewpub" as ?type) }
  UNION
  { ?item wdt:P31 wd:Q42360247 . BIND ("brewpub chain" as ?type) }
  OPTIONAL { ?item wdt:P17 ?country }
  OPTIONAL { ?item wdt:P571 ?founded }
  OPTIONAL { ?item wdt:P131 ?location }
}
ORDER BY ?type ?item

wikibase should include 'split item' feature

Opposite of merge. Make a copy of an item into a new item. Update all occurrences of item to refer to both the old and new item.

Example: brewery represents two concepts: 'brewery as a beer factory' and 'brewery as a brewing company'. I'd like to split it into brewery and brewing company, then remove 'instance of brewing company' from any item that is just a brewery building and remove 'brewery' from multinational brewing companies.

Find country via HQ for breweries

SELECT ?item ?itemLabel ?hqCountry ?hqCountryLabel ?hqLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q131734.
  filter not exists { ?item wdt:P17 ?country }
  ?item wdt:P159 ?hq .
  ?hq wdt:P17 ?hqCountry .
}

Things with a country that don't match the HQ country

SELECT ?item ?itemLabel ?country ?countryLabel ?hqCountryLabel ?hqLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P17 ?country .
  ?item wdt:P159 ?hq .
  ?hq wdt:P17 ?hqCountry .
  FILTER ( ?hqCountry != ?country ) .
  filter not exists { ?country wdt:P31 wd:Q3024240 } .
}

Musicians that killed themselves

SELECT DISTINCT ?item ?itemLabel ?dod ?death ?deathLabel ?countryLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P1196 wd:Q10737 .
  ?item wdt:P31 wd:Q5 .
  OPTIONAL { ?item wdt:P570 ?dod . }
  OPTIONAL { ?item wdt:P509 ?death . }
  OPTIONAL { ?item wdt:P27 ?country . }
  {
    ?item wdt:P106/wdt:P279* wd:Q639669 .
  } UNION {
    ?item wdt:P106/wdt:P279* wd:Q177220 .
  } UNION {
    ?item wdt:P106/wdt:P279* wd:Q753110 .
  }
} ORDER BY DESC(?dod)

Recent deaths

SELECT DISTINCT ?item ?itemLabel ?dob ?dod ?placeLabel ?deathLabel
                (GROUP_CONCAT(DISTINCT(?jobLabel); separator=", ") as ?jobs)
                (GROUP_CONCAT(DISTINCT(?countryLabel); separator=", ") as ?country)
WHERE {
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
    ?job rdfs:label ?jobLabel .
    ?country rdfs:label ?countryLabel .
    ?item rdfs:label ?itemLabel .
    ?place rdfs:label ?placeLabel .
  }
  ?item wdt:P31 wd:Q5 .  ?item wdt:P570 ?dod .
  OPTIONAL { ?item wdt:P106 ?job . } OPTIONAL { ?item wdt:P20 ?place . } OPTIONAL { ?item wdt:P569 ?dob . }
  OPTIONAL { ?item wdt:P1196 ?death . } OPTIONAL { ?item wdt:P27 ?country . }
  FILTER (?dod >= "2017-11-00T00:00:00Z"^^xsd:dateTime) FILTER (?dod <= "2017-11-15T00:00:00Z"^^xsd:dateTime)
}
GROUP BY ?item ?itemLabel ?dob ?dod ?placeLabel ?deathLabel ORDER BY DESC(?dod)

Family names with a religion

SELECT ?family ?familyLabel ?religionLabel {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?family wdt:P31 wd:Q101352 .
  ?family wdt:P140 ?religion .
}

Current UK members of parliament

SELECT ?item ?itemLabel ?dob ?countryLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P39 wd:Q30524710.
  OPTIONAL { ?item wdt:P569 ?dob }
  OPTIONAL { ?item wdt:P27 ?country }
}

Tech start-up founders

SELECT ?founder ?founderLabel ?company ?companyLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?company wdt:P31 wd:Q4830453 .
  {
    ?company wdt:P452 wd:Q11661
  } UNION {
    ?company wdt:P452 wd:Q21157865
  } UNION {
    ?company wdt:P452 wd:Q880371
  } UNION {
    ?company wdt:P452 wd:Q638608
  } UNION {
    ?company wdt:P452 wd:Q75
  }
  ?company wdt:P112 ?founder .
}

Cities

SELECT ?item ?itemLabel (sample(?pop) as ?pop) WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31/wdt:P279* wd:Q515 .
  ?item wdt:P1082 ?pop .
  FILTER (?pop > 500000)
} group by ?item ?itemLabel

625 results.

Looking for missing "city with millions of inhabitants"

Looking for cities with more than 1 million people without being instance of "city with millions of inhabitants".

This isn't working correctly.

SELECT ?item ?itemLabel ?pop WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q515 .
  ?item wdt:P1082 ?pop .
  FILTER NOT EXISTS {?item wdt:P31 wd:Q1637706 . }
  FILTER (?pop > 1000000)
}

Country short names

I'd like to write a query that includes country names, but I prefer USA over United States of America. Wikidata has a 'short name' property, but it has names in multiple languages, I want one in English. Some countries don't have a short name. I want, short name in English if it exists, otherwise regular name in English.

Books in English in the Welsh language Wikipedia that are missing English labels

SELECT ?item ?itemLabel WHERE {
 ?item wdt:P31 wd:Q571.
 ?item wdt:P407 wd:Q1860 .
 ?item rdfs:label ?itemLabel
 FILTER(LANG(?itemLabel) = "cy")
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
}

Books in English in that are missing English labels

SELECT DISTINCT ?item ?itemLabel (LANG(?itemLabel) as ?lang) WHERE {
 ?item wdt:P31 wd:Q571.
 ?item wdt:P407 wd:Q1860 .
 ?item rdfs:label ?itemLabel
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
}

Humans that have a Welsh label, but not an English label

SELECT ?item ?itemLabel WHERE {
 ?item wdt:P31 wd:Q5.
 ?item rdfs:label ?itemLabel
 FILTER(LANG(?itemLabel) = "cy")
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
}

UK people without an English label

SELECT ?item (GROUP_CONCAT(DISTINCT(?itemLabel); separator="|") as ?labels) WHERE {
 ?item wdt:P31 wd:Q5.
 ?item wdt:P27 wd:Q145 .
 ?item rdfs:label ?itemLabel
 FILTER(LANG(?itemLabel) != "en")
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
} GROUP BY ?item

List of languages, writing systems and Wikimedia language code

SELECT ?item ?itemLabel ?writing ?writingLabel ?code WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q34770 .
  ?item wdt:P282 ?writing .
  ?item wdt:P424 ?code .
}

Find bad OSM Key or Tag

SELECT ?item ?itemLabel ?osm WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P1282 ?osm.
  FILTER NOT EXISTS {
    FILTER regex(?osm,'^Key:')
  }
  FILTER NOT EXISTS {
    FILTER regex(?osm,'^Tag:')
  }
}

Things with OSM Key or Tag but no English language label

SELECT ?item ?osm WHERE {
  ?item wdt:P1282 ?osm.
  FILTER(NOT EXISTS {
    ?item rdfs:label ?itemLabel
    FILTER(LANG(?itemLabel) = "en")
  })
}

Parks with a Commons category, but no English language label

SELECT ?item (GROUP_CONCAT(DISTINCT(?itemLabel); separator="|") as ?labels) ?cat WHERE {
 ?item wdt:P373 ?cat .
 ?item wdt:P31 wd:Q22698 .
 ?item rdfs:label ?itemLabel .
 FILTER(LANG(?itemLabel) != "en")
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
} GROUP BY ?item ?cat

People with country of citizenship set to China (region)

SELECT ?item ?itemLabel ?dob WHERE {
  ?item wdt:P27 wd:Q29520 .
  OPTIONAL { ?item wdt:P569 ?dob }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

2,986 Results

Midland Metro stops

Fix district of India items

Example: https://en.wikipedia.org/wiki/List_of_districts_in_Telangana

Check each item for 'instance of=district of India', 'country=India' and 'located in=Telangana'

Churches in Norway

SELECT ?item ?itemLabel ?coords WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31/wdt:P279* wd:Q16970 .
  ?item wdt:P17 wd:Q20 .
  OPTIONAL { ?item wdt:P625 ?coords }
}

Admin subdivisions of Cambridgeshire (county council area)

SELECT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  VALUES ?start { wd:Q21272276 } .
  ?start wdt:P150 ?item .
}

Ceremonial counties in East of England

SELECT DISTINCT ?item ?itemLabel ?startLabel WHERE {
  VALUES ?start { wd:Q48006 } .
  ?item wdt:P31 wd:Q180673 .
  ?item wdt:P131 ?start .
  ?item wdt:P31 ?isa .
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q9046617 } .
  FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q19953632 } .
  FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q15893266 } .
  FILTER NOT EXISTS { ?item wdt:P576 ?end } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?itemLabel

Districts of India in Telangana

SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item wdt:P131 wd:Q677037 .
  ?item wdt:P31 wd:Q1149652 .
  FILTER NOT EXISTS { ?item wdt:P576 ?end } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?itemLabel

Continents and country counts

Ignore continents with only one country

SELECT ?continent ?continentLabel ?count WHERE {
{
SELECT ?continent ?continentLabel (COUNT(?country) AS ?count) WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?country wdt:P30 ?continent .
  ?country wdt:P31 wd:Q6256 .
}
GROUP BY ?continent ?continentLabel
ORDER BY ?continentLabel
}
FILTER (?count > 1)
}

Pubs in the UK tagged as inns.

List of pubs with the word 'inn' in the name. Incorrectly tagged as pubs. 2,857 results.

SELECT ?item ?itemLabel WHERE
{
  ?item wdt:P31 wd:Q256020 .
  ?item wdt:P17 wd:Q145 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Languages with an IETF language tag

SELECT ?item ?itemLabel ?code {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P305 ?code .
} ORDER BY ?code

MPs elected since 2005

SELECT ?item ?itemLabel ?dob WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P39 ?parliament  .
  ?parliament wdt:P279 wd:Q16707842 .
  ?parliament wdt:P571 ?start .
  ?item wdt:P569 ?dob .
  FILTER (?start > "2005-01-00T00:00:00Z"^^xsd:dateTime)
} ORDER BY DESC (?dob)

Need to create items to represent councils

Check OSM using this Overpass query:

[out:xml][timeout:25];
rel[council_name]
out bb tags;

Items exist for council elections, but not the councils. Need to link the council to the place using legislative body (P194) and elections.

Correct anything that has 'located in the administrative territorial entity (P131)' pointed at a council.

department of Argentina without a label in English

27 results

SELECT ?item ?itemLabel WHERE {
 ?item wdt:P31 wd:Q952274.
 ?item rdfs:label ?itemLabel
 FILTER(LANG(?itemLabel) = "es")
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
}

administrative territorial entity of Argentina without an English label

SELECT ?item ?itemLabel ?countryLabel WHERE {
 ?item wdt:P31/wdt:P279* wd:Q3042547 .
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],es" }
 OPTIONAL { ?item wdt:P17 ?country . }
 FILTER(NOT EXISTS {
   ?item rdfs:label ?itemLabel2
   FILTER(LANG(?itemLabel2) = "en")
 })
}

people with citizenship set to language by mistake

select ?person ?personLabel ?item ?itemLabel where {
  ?item wdt:P31 wd:Q34770 .
  ?person wdt:P27 ?item .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

141 results

people with place of death as a year item

select ?person ?personLabel ?item ?itemLabel where {
  ?item wdt:P31 wd:Q577 .
  ?person wdt:P20 ?item .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

19 results

Instance of 'consulate', should be 'consulate general'

select ?item ?itemLabel where {
  ?item wdt:P31 wd:Q7843791 .
  ?item rdfs:label ?label .
  FILTER regex(?label, 'eneral')
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

districts of the United Kingdom in Oxfordshire

SELECT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q17601336 .
  ?item wdt:P131 wd:Q23169 .
}

books written by journalists

15,189 results

select ?person ?personLabel ?book ?bookLabel ?date where {
  ?person wdt:P106 wd:Q1930187 .
  ?book wdt:P31 wd:Q571 .
  ?book wdt:P50 ?person .
  ?book wdt:P577 ?date .
  service wikibase:label { bd:serviceParam wikibase:language "en" }
} order by desc(?date)

books written by health professionals

select distinct ?person ?personLabel ?book ?bookLabel ?date where {
  ?person wdt:P106/wdt:P279* wd:Q11974939 .
  ?book wdt:P31 wd:Q571 .
  ?book wdt:P50 ?person .
  ?book wdt:P577 ?date .
  service wikibase:label { bd:serviceParam wikibase:language "en" }
} order by desc(?date)

administrative territorial entity of a single country

exclude historical countries

215 results.

select ?item ?itemLabel ?country ?countryLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P279 wd:Q15916867 .
  ?item wdt:P17 ?country .
  filter not exists {
    ?country wdt:P31 wd:Q3024240 .
  }
}

Tall buidings

SELECT ?item ?itemLabel ?height WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q811979 .
  ?item p:P2048/psn:P2048/wikibase:quantityAmount ?height .
  filter (?height > 200)
}

Streets named after people

select distinct ?item ?itemLabel ?country ?countryLabel ?namedAfter ?namedAfterLabel ?job ?jobLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 wd:Q79007 .
  optional {?item wdt:P17 ?country}
  ?item wdt:P138 ?namedAfter .
  ?namedAfter wdt:P31 wd:Q5 .
  optional {?namedAfter wdt:P106 ?job }
} limit 100

things named after physicist

751 results

select distinct ?item ?itemLabel ?isa ?isaLabel ?itemCountry ?itemCountryLabel ?person ?personLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 ?isa .
  ?item wdt:P17 ?itemCountry .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106/wdt:P279* wd:Q169470 .
  filter (?isa != wd:Q79007)
}

Airports named after people by job

202 results

select distinct  ?job ?jobLabel (count(*) as ?count) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106/wdt:P279* ?job .
  ?job wdt:P31/wdt:P279* wd:Q28640 .
} GROUP BY ?job ?jobLabel ORDER BY DESC(?count)

Airports named after poets

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?person ?personLabel  where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
}

Airports named after poets with date of birth and death

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?person ?personLabel ?birth ?death where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  ?statement ps:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
  optional { ?person wdt:P569 ?birth }
  optional { ?person wdt:P570 ?death }

  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
}

How many airports are named after a person in each country

91 countries

select ?itemCountry ?itemCountryLabel (count(*) as ?count) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
} group by ?itemCountry ?itemCountryLabel order by DESC(?count)

Airports named after poets with date of birth and death

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?place ?placeLabel ?person ?personLabel (year(?dob) as ?born) (year(?dod) as ?died) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
  optional { ?item wdt:P931 ?place }
  optional { ?person wdt:P569 ?dob }
  optional { ?person wdt:P570 ?dod }
}

Type of things stations are named after

select distinct ?isa ?isaLabel (sample(?item) as ?sample) (count(*) as ?count) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q55488 .
  ?item p:P138 ?statement .
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31 ?isa .
  filter (?isa != wd:Q5 )
  filter not exists { ?person wdt:P31/wdt:P279* wd:Q486972 }
  filter not exists { ?person wdt:P31/wdt:P279* wd:Q56061 }
} group by ?isa ?isaLabel order by desc(?count)

Bridges named after poets

41 results

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?place ?placeLabel ?person ?personLabel (year(?dob) as ?born) (year(?dod) as ?died) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q12280 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P106 wd:Q49757 .
  optional { ?item wdt:P131 ?place }
  optional { ?person wdt:P569 ?dob }
  optional { ?person wdt:P570 ?dod }
}

Things named after themselves

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?isa ?isaLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P138 ?item .
  optional { ?item wdt:P31 ?isa }
  optional { ?item wdt:P17 ?itemCountry }
}

Island airports

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?place ?placeLabel ?island ?islandLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item wdt:P931 ?place .
  ?place wdt:P31 wd:Q23442 .
  optional { ?item wdt:P5130 ?island }
}

Islands named after poets

3 results

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?place ?placeLabel ?person ?personLabel (year(?dob) as ?born) (year(?dod) as ?died) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q23442 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
  optional { ?item wdt:P131 ?place }
  optional { ?person wdt:P569 ?dob }
  optional { ?person wdt:P570 ?dod }
}

Things (other than streets) named after people

select distinct ?item ?itemLabel ?isa ?isaLabel ?itemCountry ?itemCountryLabel ?person ?personLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 ?isa .
  ?item wdt:P17 ?itemCountry .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106/wdt:P279* wd:Q169470 .
  filter (?isa != wd:Q79007)
}

Airports named after boxers

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?person ?personLabel  where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q11338576 .
}

Railway stations named after jobs

155 results

select distinct  ?job ?jobLabel (count(*) as ?count) (sample(?item) as ?sample) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q55488 .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 ?job .
} GROUP BY ?job ?jobLabel ORDER BY DESC(?count)

Airports named after possibly living people

32 results

Need to add a special case to handle married couple for Clinton National Airport

select distinct ?item ?itemLabel ?itemCountry ?itemCountryLabel ?person ?personLabel ?birth where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  ?statement ps:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  optional { ?person wdt:P569 ?birth }
  FILTER NOT EXISTS { ?person wdt:P570 ?death }
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
}

Airports named after librarians

select ?item ?itemLabel ?person ?personLabel  where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P138+ ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106/wdt:P279* wd:Q182436 .
}

Airports named after poets, with photos and coordinates

select distinct ?item ?itemLabel ?image ?coordinates ?itemCountry ?itemCountryLabel ?place ?placeLabel ?person ?personLabel (year(?dob) as ?born) (year(?dod) as ?died) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q1248784 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  optional { ?item wdt:P625 ?coordinates }
  optional { ?item wdt:P18 ?image }
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
  optional { ?item wdt:P931 ?place }
  optional { ?person wdt:P569 ?dob }
  optional { ?person wdt:P570 ?dod }
}

Railway stations named after literary works

select distinct ?item ?itemLabel ?image ?coordinates ?itemCountry ?itemCountryLabel ?place ?placeLabel ?person ?personLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q55488 .
  ?item wdt:P17 ?itemCountry .
  ?item p:P138 ?statement .
  optional { ?item wdt:P625 ?coordinates }
  optional { ?item wdt:P18 ?image }
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31/wdt:P279* wd:Q7725634 .
  optional { ?item wdt:P931 ?place }
}

What type of things are stations named after, excluding people

select distinct ?isa ?isaLabel (sample(?item) as ?sample) (count(*) as ?count) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q55488 .
  ?item p:P138 ?statement .
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31 ?isa .
  filter (?isa != wd:Q5 )
  filter not exists { ?person wdt:P31/wdt:P279* wd:Q486972 }
  filter not exists { ?person wdt:P31/wdt:P279* wd:Q56061 }
} group by ?isa ?isaLabel order by desc(?count)

Books by surgeons

select distinct ?person ?personLabel ?book ?bookLabel ?date where {
  ?person wdt:P106/wdt:P279* wd:Q774306 .
  ?book wdt:P31 wd:Q571 .
  ?book wdt:P50 ?person .
  ?book wdt:P577 ?date .
  service wikibase:label { bd:serviceParam wikibase:language "en" }
} order by desc(?date)

Married couples

486 results. I few without labels in English

select ?item ?itemLabel {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q3046146 .
}

Asteroids named after poets

select distinct ?item ?itemLabel ?person ?personLabel (year(?dob) as ?born) (year(?dod) as ?died) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q3863 .
  ?item p:P138 ?statement .
  ?statement ps:P138/wdt:P138* ?person .
  FILTER NOT EXISTS { ?statement pq:P582 ?endTime }
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
  optional { ?person wdt:P569 ?dob }
  optional { ?person wdt:P570 ?dod }
}

Things named after poets

select distinct ?isa ?isaLabel  (count(*) as ?count) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 ?isa .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q49757 .
} group by ?isa ?isaLabel order by desc(?count)

Jobs of people with impact craters named after them

select distinct  ?job ?jobLabel (count(*) as ?count) (sample(?item) as ?sample) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q55818 .
  ?item wdt:P138+ ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 ?job .
} GROUP BY ?job ?jobLabel ORDER BY DESC(?count)

Things named after writers

select distinct ?isa ?isaLabel  (count(*) as ?count) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 ?isa .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q36180 .
} group by ?isa ?isaLabel order by desc(?count)

what types of things are named after french anarchists?

select distinct ?isa ?isaLabel  (count(*) as ?count) (sample(?item) as ?sample) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 ?isa .
  ?item wdt:P138 ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q12961474 .
  ?person wdt:P27 wd:Q142 .
} group by ?isa ?isaLabel order by desc(?count)

select distinct ?item ?itemLabel ?isa ?isaLabel ?person ?personLabel where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P138 ?person .
  ?item wdt:P31 ?isa .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 wd:Q12961474 .
  ?person wdt:P27 wd:Q142 .
}

Count of paintings with an image

result: 94,291

select (count(*) as ?count) where {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  ?painting wdt:P31 wd:Q3305213 .
  ?painting wdt:P18 ?image .
}

Jobs of people with peninsulas named after them

select distinct  ?job ?jobLabel (count(*) as ?count) (sample(?item) as ?sample) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31/wdt:P279* wd:Q34763 .
  ?item wdt:P138+ ?person .
  ?person wdt:P31 wd:Q5 .
  ?person wdt:P106 ?job .
} GROUP BY ?job ?jobLabel ORDER BY DESC(?count)

Type of things named after statisticians

select distinct ?isa ?isaLabel  (count(*) as ?count) (sample(?item) as ?sample) where {
  service wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P31 ?isa .
  ?item wdt:P138 ?person .
  ?person wdt:P106 wd:Q2732142 .
} group by ?isa ?isaLabel order by desc(?count)

Paintings with value of P180 depicts statement

select ?painting ?paintingLabel ?article ?depicts ?depictsLabel where {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  ?painting wdt:P31 wd:Q3305213 .
  ?article schema:about ?painting .
  ?article schema:isPartOf <https://en.wikipedia.org/>.
  ?painting wdt:P180 ?depicts
} LIMIT 100

Simple version of airports named after poets

select ?airport ?poet where {
  ?airport wdt:P31/wdt:P279* wd:Q1248784 .
  ?airport wdt:P138 ?poet .
  ?poet wdt:P106 wd:Q49757 .
}

Paintings with an enwiki sitelink but no depicts (P180) statement

select ?painting ?paintingLabel ?image ?article where {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  ?painting wdt:P31 wd:Q3305213 .
  ?painting wdt:P18 ?image .
  ?article schema:about ?painting .
  ?article schema:isPartOf <https://en.wikipedia.org/>.
  FILTER NOT EXISTS { ?painting wdt:P180 ?depicts }
}

painting depicts (P180) counts

causes timeout

select ?depicts ?depictsLabel (count(*) as ?count) where {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  ?painting wdt:P31 wd:Q3305213 .
  ?painting wdt:P180 ?depicts
} group by ?depicts ?depictsLabel order by desc(?count)

painting with image, missing depicts (P180) and no enwiki or commons category

59653 results

select ?painting ?paintingLabel where { SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } ?painting wdt:P31 wd:Q3305213 . ?painting wdt:P18 ?image . FILTER NOT EXISTS { ?painting wdt:P373 ?commons } FILTER NOT EXISTS { ?painting wdt:P180 ?depicts } FILTER NOT EXISTS { ?article schema:about ?painting . ?article schema:isPartOf https://en.wikipedia.org/. } } limit 100

entities with both ISO 3166-1 alpha 2 and alpha 3 code.

SELECT ?item ?itemLabel ?iso_alpha_2 ?iso_alpha_3 WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P297 ?iso_alpha_2 .
  ?item wdt:P298 ?iso_alpha_3 .
}

labels in all languages for country-like entities

SELECT ?item
       ?alpha2
       ?alpha3
       (GROUP_CONCAT(DISTINCT(?label); separator = "|") AS ?label_list)
WHERE {
  OPTIONAL { ?item wdt:P297 ?alpha2 }
  OPTIONAL { ?item wdt:P298 ?alpha3 }
  ?item rdfs:label ?label .
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q3024240 }
} GROUP BY ?item ?alpha2 ?alpha3

english label, aliases, demonyms for country-like entities

SELECT ?item
       ?itemLabel
       ?alpha2
       ?alpha3
       (GROUP_CONCAT(DISTINCT(?altLabel); separator = "|") AS ?altLabel_list)
       (GROUP_CONCAT(DISTINCT(?demonym); separator = "|") AS ?demonym_list)
WHERE {
  {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
      OPTIONAL { ?item wdt:P297 ?alpha2 }
      OPTIONAL { ?item wdt:P298 ?alpha3 }
  } UNION {
      VALUES ?item { wd:Q458 wd:Q1065 }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q3024240 }
  OPTIONAL { ?item skos:altLabel ?altLabel }
  OPTIONAL { ?item wdt:P1549 ?demonym }
} GROUP BY ?item ?itemLabel ?alpha2 ?alpha3

Countries and codes

SELECT ?item ?itemLabel ?alpha2 ?alpha3 (GROUP_CONCAT(DISTINCT(?altLabel); separator = "|") AS ?altLabel_list) WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P297 ?alpha2 }
  OPTIONAL { ?item wdt:P298 ?alpha3 }
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q3024240 }
  OPTIONAL {
    ?item skos:altLabel ?altLabel .
    FILTER (lang(?altLabel) = "en")
    FILTER (strlen(?altLabel) > 4)
  }
} GROUP BY ?item ?itemLabel ?alpha2 ?alpha3


SELECT ?item ?itemLabel ?alpha2 ?alpha3 (GROUP_CONCAT(DISTINCT(?altLabel); separator = "|") AS ?altLabel_list) WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P297 ?alpha2 }
  OPTIONAL { ?item wdt:P298 ?alpha3 }
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q3024240 }
  OPTIONAL { ?item skos:altLabel ?altLabel }
} GROUP BY ?item ?itemLabel ?alpha2 ?alpha3
limit 10

UK council websites

SELECT DISTINCT ?item ?itemLabel ?countryLabel ?url WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  VALUES (?isa) { (wd:Q1187580) (wd:Q1006876) (wd:Q3957)} .
  ?item wdt:P31 ?isa .
  ?item wdt:P17 wd:Q145 .
  ?item wdt:P856 ?url .
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q19953632 }
}

UK town websites

565 results

SELECT DISTINCT ?item ?itemLabel ?url WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q3957 .
  ?item wdt:P17 wd:Q145 .
  ?item wdt:P856 ?url .
}

Pubs in Westminster

78 results

SELECT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q212198 .
  ?item wdt:P131 wd:Q179351 .
}

OSM tags that start with Tag:shop

164 results

SELECT ?item ?itemLabel ?osm WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P1282 ?osm .
  FILTER ( STRSTARTS(?osm, "Tag:shop") )
}

Photos of caf├ęs

190 results

SELECT ?item ?itemLabel ?img WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q30022 .
  ?item wdt:P18 ?img .
}

Pubs in Westminster called the Red Lion

defaultView:Map

SELECT ?item ?itemLabel ?coords WHERE { ?item rdfs:label ?itemLabel. ?item wdt:P31 wd:Q212198 . ?item wdt:P131 wd:Q179351 . ?item wdt:P625 ?coords . FILTER(?itemLabel = "Red Lion"@en) }

Things with the same photo

PREFIX geof: <http://www.opengis.net/def/geosparql/function/>

SELECT DISTINCT ?item1 ?item1Label ?isa1 ?isa1Label  ?item2 ?item2Label ?isa2 ?isa2Label WHERE {
  ?item1 wdt:P18 ?img.
  ?item2 wdt:P18 ?img.
  ?item1 wdt:P625 ?coords1.
  ?item2 wdt:P625 ?coords2.
  ?item1 wdt:P17 wd:Q145 .
  ?item1 wdt:P31 ?isa1 .
  ?item2 wdt:P31 ?isa2 .
  BIND(geof:distance(?coords1, ?coords2) AS ?dist)
  FILTER(?dist < 2 && ?item1 != ?item2 && ?isa1 = ?isa2 && ?isa1 != wd:Q18536594 && ?isa1 != wd:Q55488)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} limit 300

Ruins in the UK

select ?item ?itemLabel ?nhle {
  ?item wdt:P17 wd:Q145 .
  ?item wdt:P1216 ?nhle .
  ?item rdfs:label ?itemLabel .
  FILTER ( STRSTARTS(?itemLabel, "Remains of") )
}

Church ruins

56 results. These should be changed to: church ruin (Q17485079)

select ?item ?itemLabel ?country ?countryLabel {
  ?item wdt:P31 wd:Q109607 .
  ?item wdt:P31 wd:Q16970 .
  OPTIONAL {
    ?item wdt:P17 ?country
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

castle ruins

167 results. These should be changed to: castle ruin (Q17715832)

SELECT ?item ?itemLabel ?country ?countryLabel WHERE {
  ?item wdt:P31 wd:Q109607.
  ?item wdt:P31 wd:Q23413.
  OPTIONAL { ?item wdt:P17 ?country. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

district of England with parent to child relationship missing

select ?item ?itemLabel ?parent ?parentLabel {
  ?item wdt:P31/wdt:P279* wd:Q349084 .
  ?item wdt:P131 ?parent .
  FILTER NOT EXISTS { ?parent wdt:P150 ?item }
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q9046617 }
  FILTER NOT EXISTS { ?item wdt:P31 wd:Q19953632 }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Find things that should be instance of a subclass

Fails with a timeout

SELECT ?item ?itemLabel ?class ?classLabel ?subclass1Label ?subclass2Label WHERE {
  ?item wdt:P31 ?subclass1 .
  ?item wdt:P31 ?subclass2 .
  ?subclass1 wdt:P279* wd:Q35145743 .
  ?subclass2 wdt:P279* wd:Q35145743 .
  ?item wdt:P17 wd:Q145 .
  ?class wdt:P279 ?subclass1 .
  ?class wdt:P279 ?subclass2 .
  ?class wdt:P31/wdt:P279* wd:Q35145743 .
  FILTER (?subclass1 != ?subclass2)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} LIMIT 100

states with limited recognition

SELECT ?country ?countryLabel ?iso WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    ?country p:P31 ?statement .
    ?statement ps:P31 wd:Q15634554 .
    FILTER NOT EXISTS { ?statement pq:P582 ?end }
    FILTER NOT EXISTS { ?country wdt:P31/wdt:P279* wd:Q3024240 }
    OPTIONAL { ?country wdt:P297 ?iso }
}

Footballers

SELECT ?player ?playerLabel ?dob ?dod ?team ?teamLabel ?start ?end WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?teamStatement pq:P580 ?start }
  OPTIONAL { ?teamStatement pq:P582 ?end }
  {
    SELECT ?player ?dob ?dod (SAMPLE(?team) AS ?team) (SAMPLE(?teamStatement) AS ?teamStatement) WHERE {
      ?player wdt:P21 wd:Q6581097.
      ?player wdt:P31 wd:Q5.
      ?player p:P54 ?teamStatement .
      ?teamStatement ps:P54 ?team .
      ?player wdt:P106 wd:Q937857.
      ?team wdt:P17 wd:Q145.
      ?team wdt:P31 wd:Q476028.
      ?team wdt:P118 wd:Q9448.
      OPTIONAL { ?player wdt:P569 ?dob. }
      OPTIONAL { ?player wdt:P570 ?dod. }
    }
    GROUP BY ?player ?dob ?dod
    HAVING ((COUNT(?team)) = 1)
  }
}

Items in Stroud

#defaultView:Map
SELECT ?item ?itemLabel ?coords ?image WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  SERVICE wikibase:around {
    ?item wdt:P625 ?coords.
    bd:serviceParam wikibase:center "Point(-2.21 51.74)"^^geo:wktLiteral .
    bd:serviceParam wikibase:radius "1" .
  }
  OPTIONAL { ?item wdt:image ?image. }
  ?item wdt:P131 ?stroud.
}

Places called Glasgow, using Mediawiki search API

SELECT DISTINCT ?item ?itemLabel ?itemDescription ?parent ?parentLabel ?num WHERE {
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "EntitySearch" .
      bd:serviceParam wikibase:endpoint "www.wikidata.org" .
      bd:serviceParam mwapi:search "glasgow" .
      bd:serviceParam mwapi:language "en" .
      ?item wikibase:apiOutputItem mwapi:item .
      ?num wikibase:apiOrdinal true .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31/wdt:P279* wd:Q2221906 .
  FILTER NOT EXISTS { ?item wdt:P31/wdt:P279* wd:Q192611 }
  OPTIONAL {
    ?item p:P131 ?statement .
    ?statement ps:P131 ?parent .
    FILTER NOT EXISTS { ?statement pq:P582 ?x }
  }
} ORDER BY ASC(?num) LIMIT 50

brewery buildings with coordinates, not in the Czech Republic

SELECT ?item ?itemLabel ?coords ?country ?countryLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q57778855 .
  ?item wdt:P625 ?coords .
  FILTER NOT EXISTS { ?item wdt:P17 wd:Q213 }
  OPTIONAL { ?item wdt:P17 ?country }
}

restaurants with steakhouse in the name

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q11707 .
  ?item rdfs:label ?itemLabel.
  FILTER(CONTAINS(LCASE(?itemLabel), "steakhouse"@en)).
}

tram stops

1,896 results

sparql SELECT ?item ?itemLabel ?coords ?loc ?locLabel ?owner ?ownerLabel ?countryLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item wdt:P31/wdt:P279* wd:Q2175765. OPTIONAL { ?item wdt:P625 ?coords. } OPTIONAL { ?item wdt:P131 ?loc. } OPTIONAL { ?item wdt:P17 ?country. } OPTIONAL { ?item wdt:P18 ?image. } OPTIONAL { ?item wdt:P127 ?owner. } } ORDER BY ?country

tram stops in San Francisco

101 results

sparql SELECT ?place ?placeLabel ?coord ?loc ?locLabel WHERE { wd:Q62 wdt:P625 ?sfLoc . SERVICE wikibase:around { ?place wdt:P625 ?coord . bd:serviceParam wikibase:center ?sfLoc . bd:serviceParam wikibase:radius "50" . } . FILTER EXISTS { ?place wdt:P31 wd:Q2175765 } . OPTIONAL { ?place wdt:P131 ?loc } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

UK railway stations without a photo

sparql SELECT DISTINCT ?item ?itemLabel ?code WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item wdt:P31/wdt:P279* wd:Q55488 . ?item wdt:P4755 ?code. FILTER NOT EXISTS { ?item wdt:P18 ?image } }

Thinks with a UK railway station code

sparql SELECT ?code ?item ?itemLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item wdt:P4755 ?code . } ORDER BY ?code

UK railway station without a 'named after' statement

953 results

sparql SELECT DISTINCT ?item ?itemLabel ?code WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item wdt:P31/wdt:P279* wd:Q55488 . ?item wdt:P4755 ?code. FILTER NOT EXISTS { ?item wdt:P138 ?name } } order by strlen(str(?itemLabel))

Items that represent authors of a book

27,063 results

sparql SELECT distinct ?author ?authorLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?book wdt:P31/wdt:P279* wd:Q571. ?book wdt:P50 ?author. }

Publishers excluding record labels

sparql SELECT DISTINCT ?item ?itemLabel ?country ?countryLabel ?location ?locationLabel ?hq ?hqLabel { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item wdt:P31/wdt:P279* wd:Q2085381 . FILTER NOT EXISTS { ?item wdt:P31 wd:Q18127 } OPTIONAL { ?item wdt:P17 ?country } OPTIONAL { ?item wdt:P276 ?location } OPTIONAL { ?item wdt:P159 ?hq } }

Airports in a given country

sparql select ?item ?itemLabel (max(?passengers) AS ?passengers) ?website ?isin ?isinLabel ?iata ?icao { ?item wdt:P31/wdt:P279* wd:Q1248784 . ?item wdt:P17 wd:Q145 . ?item wdt:P3872 ?passengers . optional { ?item wdt:P131 ?isin } optional { ?item wdt:P856 ?website } optional { ?item wdt:P238 ?iata } optional { ?item wdt:P239 ?icao } FILTER NOT EXISTS { ?item wdt:P576 ?end } FILTER NOT EXISTS { ?item wdt:P3999 ?close } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?item ?itemLabel ?website ?isin ?isinLabel ?iata ?icao ORDER BY desc(?passengers)

Airports in a given country

sparql select ?item ?itemLabel (max(?passengers) AS ?passengers) ?website ?country ?countryLabel ?iata ?icao { ?item wdt:P31/wdt:P279* wd:Q1248784 . ?item wdt:P17 ?country . ?item wdt:P3872 ?passengers . optional { ?item wdt:P856 ?website } optional { ?item wdt:P238 ?iata } optional { ?item wdt:P239 ?icao } FILTER NOT EXISTS { ?item wdt:P576 ?end } FILTER NOT EXISTS { ?item wdt:P3999 ?close } FILTER ( ?country != wd:Q148 ) FILTER ( ?passengers > 1000000 ) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?item ?itemLabel ?website ?country ?countryLabel ?iata ?icao ORDER BY desc(?passengers)

Airports in a given country

sparql select ?item ?itemLabel ?passengers ?website ?iata ?icao { ?item wdt:P31/wdt:P279* wd:Q1248784; p:P3872 [pq:P585 ?date; ps:P3872 ?passengers] FILTER NOT EXISTS {?item p:P3872 [pq:P585 ?date_] FILTER (?date_ > ?date)} ?item wdt:P17 wd:Q145 . optional { ?item wdt:P856 ?website } optional { ?item wdt:P238 ?iata } optional { ?item wdt:P239 ?icao } FILTER NOT EXISTS { ?item wdt:P576 ?end } FILTER NOT EXISTS { ?item wdt:P3999 ?close } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY desc(?passengers)