Question: What are the countries and the percentage of out-of-school children in their population, rounded to two decimal places (e.g. literals such as '7.86')?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?country ?OOS { ?country wdt:P31 wd:Q6256 ; wdt:P1082 ?pop ; wdt:P2573 ?outOfSchool . BIND ( ROUND ( ( ?outOfSchool / ?pop * 100 ) * 100 ) / 100 AS ?OOS ) . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en" . } }

Percentage of out of school children (`number of out-of-school children (P2573)`) in population of a country


Question: What are the Nazi concentration camps or subcamps? Include the following way of finding such a camp: (1) those that are classified as a Nazi concentration camp, (2) those that are considered the subcamps, and (3) subsdiaries of Nazi concentration camps. For each one, also find its coordinates (e.g. literals such as `Point(9.1978 49.1686)'`). Each pair of camp and coordinate should only appear once.

PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT DISTINCT ?camp ?coord WHERE { { ?camp wdt:P31 ?instance_of . ?instance_of wdt:P279 * wd:Q328468 . } UNION { ?camp wdt:P31 ?instance_of . ?instance_of wdt:P279 * wd:Q1719244 . } UNION { ?mother_camp wdt:P31 ?mc_instance_of . ?mc_instance_of wdt:P279 * wd:Q328468 . ?mother_camp wdt:P355 ?camp . ?camp wdt:P31 ?instance_of . } OPTIONAL { ?camp p:P625 ?stat . ?stat ps:P625 ?coord . } }

Resumption of: https://www.wikidata.org/wiki/Wikidata:Request_a_query/Archive/2020/04#list_of_Nazi_camps


Question: What are the items located in the United Kingdom that have an inception date but do not have an "instance of" statement?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?itemLabel WHERE { ?item wdt:P17 wd:Q145 . ?item wdt:P571 ?P571 . filter not exists { ?item wdt:P31 [] . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Data quality : `inception (P571)` and `dissolved, abolished or demolished date (P576)`


Question: Who are the members of the Académie des sciences, belles-lettres et arts de Lyon, including their names, dates of birth (if available), dates of death (if available), start dates of their membership (if available), and end dates of their membership (if available)?

PREFIX pq: <http://www.wikidata.org/prop/qualifier/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?date_de_naissance ?date_de_mort ?date_de_debut ?date_de_fin WHERE { ?st ps:P463 wd:Q730513 . ?item p:P463 ?st . OPTIONAL { ?item wdt:P569 ?date_de_naissance . } OPTIONAL { ?item wdt:P570 ?date_de_mort . } OPTIONAL { ?st pq:P580 ?date_de_debut . } OPTIONAL { ?st pq:P582 ?date_de_fin . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Extraction d'un qualificatif lié à une propriété


Question: What are the current municipal formations (and its subclasses) in Russia within "Kamchatka Krai"?

PREFIX pq: <http://www.wikidata.org/prop/qualifier/> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?id WHERE { ?_ wdt:P131 * wd:Q7948 . ?locst ps:P131 ?_ . ?id p:P131 ?locst . ?__ wdt:P279 * wd:Q1849719 . ?id p:P31 / ps:P31 ?__ . MINUS { ?locst pq:P582 [] } } GROUP BY ?id

Russian districts


Question: What are the albums, their Bandcamp release IDs, and their tracks? Additionally, if available, provide the ISRC, MusicBrainz recording ID, Genius ID, and LyricsTranslate ID for each track. The results should be ordered by album label and track label.

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?album ?bc ?track ?trackLabel ?ISRC ?MB ?G ?LT WHERE { ?album wdt:P31 / wdt:P279 * wd:Q482994 . ?album wdt:P11354 ?bc . ?album wdt:P658 ?track . OPTIONAL { ?track wdt:P1243 ?ISRC . } OPTIONAL { ?track wdt:P4404 ?MB . } OPTIONAL { ?track wdt:P6218 ?G . } OPTIONAL { ?track wdt:P7212 ?LT . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } order by ?albumLabel ?trackLabel

Tracks


Question: What are the municipalities of Belgium that have not been dissolved, abolished, or demolished, and do not have an inception date in the future?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX wd: <http://www.wikidata.org/entity/> SELECT DISTINCT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q493522 . MINUS { ?item wdt:P576 [] } MINUS { ?item wdt:P571 ?date . FILTER ( DATATYPE ( ?date ) = xsd:dateTime && ?date > now () ) } SERVICE wikibase:label { bd:serviceParam wikibase:language "nl,fr,de,en" . } } ORDER BY ?itemLabel

How can future inception (`inception (P571)`) dates be excluded?


Question: What are the current municipal districts, urban districts in Russia, or administrative districts of Moscow located within Perm Krai?

PREFIX pq: <http://www.wikidata.org/prop/qualifier/> PREFIX schema: <http://schema.org/> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT DISTINCT ?id WHERE { { ?id p:P31 / ps:P31 / wdt:P279 * wd:Q2198484 . } UNION { ?id p:P31 / ps:P31 / wdt:P279 * wd:Q13626398 . } UNION { ?id p:P31 / ps:P31 / wdt:P279 * wd:Q4057820 . } ?id p:P131 ?locst . ?locst ps:P131 / wdt:P131 * wd:Q5400 . MINUS { ?locst pq:P582 [] } OPTIONAL { ?link schema:about ?id . ?link schema:isPartOf <https://en.wikipedia.org/> . } } GROUP BY ?id ?link ?idLabel

Optimizing a query for the mapframe extension


Question: What are the authors who are citizens of Norway, along with their dates of birth (if available) and works (if available)?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?author ?dob ?work WHERE { ?author wdt:P27 wd:Q20 . ?author wdt:P106 wd:Q482980 . OPTIONAL { ?author wdt:P569 ?dob } OPTIONAL { ?author ^ wdt:P50 ?work } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Where do I do wrong things?


Question: Who are citizens of Norway born before January 1, 1802 and died on or after January 1, 1802? For each person, if available, also include where they resided at.

PREFIX p: <http://www.wikidata.org/prop/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?person ?residence WHERE { ?person wdt:P31 wd:Q5 . ?person wdt:P27 wd:Q20 . ?person wdt:P569 ?birth . ?person wdt:P570 ?death . OPTIONAL { ?person p:P551 ?residenceStatement . ?residenceStatement ps:P551 ?residence . } FILTER ( ?birth < "1802-01-01" ^^ xsd:dateTime && ?death >= "1802-01-01" ^^ xsd:dateTime ) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

All norwegians born before 1802


Question: What are episodes of the eighth season of the Lego Ninjago TV series, Sons of Garmadon, including their series ordinal positions as integers (i.e. which episode in the season), if available, and ordered by that?

PREFIX pq: <http://www.wikidata.org/prop/qualifier/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?itemLabel ( xsd:integer ( ?number ) AS ?no ) WHERE { ?item p:P4908 ?statement . ?statement ps:P4908 wd:Q43133862 . OPTIONAL { ?statement pq:P1545 ?number . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } ORDER BY ?no

show qualifier


Question: Who are the participants of the exhibition "Estudiotik at. Five years of creation," and if available, their place of birth coordinates?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT distinct ?item ?coord WHERE { { wd:Q106591714 wdt:P710 ?item . } UNION { ?item wdt:P1344 wd:Q106591714 . } optional { ?item wdt:P19 / wdt:P625 ?coord . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Crear mapa con una exposición


Question: What are the names, dates of birth (if available), and dates of death (if available) of individuals who have works in the City of Pori art collection?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?itemLabel ?date_of_birth ?date_of_death WHERE { ?item wdt:P31 wd:Q5 . ?item wdt:P6379 wd:Q86443703 . OPTIONAL { ?item wdt:P569 ?date_of_birth . } OPTIONAL { ?item wdt:P570 ?date_of_death . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

List of artists in City of Pori art collection


Question: Who are the co-authors of Thomas Shafee? Return a list of tuples, where each tuple contains a pair of authors who have coauthored with Thomas Shafee on the same work, and a label of either "male" or "other" depending on whether the author is a male or not, for the first author in the triple

# Egocentric co-author graph for an author
SELECT ?author1 ?author1Label ?rgb ?author2 ?author2Label
WITH {
  SELECT (COUNT(?work) AS ?count) ?author1 ?author2 WHERE {
    # Find co-authors
    ?work wdt:P50 wd:Q38382414, ?author1, ?author2 .

  }
  GROUP BY ?author1 ?author2
  ORDER BY DESC(?count)
} AS %authors
WITH {
  SELECT ?author1 ?author2 ?rgb WHERE {
    INCLUDE %authors

    # Exclude self-links
    FILTER (?author1 != ?author2)

    # Color according to gender
    OPTIONAL {
      ?author1 wdt:P21 ?gender1 .
      BIND( IF(?gender1 = wd:Q6581097, "male", "other") AS ?rgb)
    }
  }
} AS %result
WHERE {
  INCLUDE %result
  # Label the results
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,de,ru,es,zh,jp". }
}

Clash between COUNT and SERVICE wikibase:label ?


Question: What are the political offices held by the heads of governmen for each region in Paphos District in the Republic of Cyprus?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?authority WHERE { ?authority wdt:P131 wd:Q59133 . ?authority wdt:P1313 ?item . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } order by desc ( ?itemLabel )

office held by head of government


Question: What are the paintings whose Iconclass.org notation starting with "71A", along with their Iconclass notation values, and, if available, the corresponding entities that have the same Iconclass notation?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?itemLabel ?value ?is ?isLabel WHERE { ?item wdt:P31 wd:Q3305213 ; wdt:P1257 ?value . FILTER ( regex ( ?value , "^71A.*$" ) ) OPTIONAL { ?is wdt:P1256 ?value } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Wildcard characters in wdqs/sparql ?


Question: What are the occupations of people who were born in Utah? For each tuple include the person and their occupation.

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?person ?personLabel ?occupation WHERE { { ?person wdt:P19 wd:Q829 . } UNION { ?person wdt:P19 ?placeofbirth . ?placeofbirth wdt:P131 + wd:Q829 . } ?person wdt:P106 ?occupation . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Occupations of people born in Utah


Question: What are the 40 western-most towns or cities located in Alabama, and what are their longitudes and coordinates?

PREFIX psv: <http://www.wikidata.org/prop/statement/value/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT DISTINCT ?item ?long ?coords WHERE { VALUES ?town_city { wd:Q3957 wd:Q515 } . ?item wdt:P31 / wdt:P279 * ?town_city . ?item wdt:P131 * wd:Q173 . ?item p:P625 / psv:P625 / wikibase:geoLongitude ?long . ?item wdt:P625 ?coords SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } ORDER BY ?long LIMIT 40

Most western city or town in Alabama?


Question: What are the taxons of remarkable trees? For each taxon, also return its taxon rank  and count how many common names it has.

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?taxon ?rank ( COUNT ( ?commonname ) as ?commonnamecount ) WHERE { { SELECT ?taxon WHERE { ?item wdt:P31 wd:Q811534 ; wdt:P31 ?taxon } GROUP BY ?taxon } ?taxon wdt:P105 ?rank . OPTIONAL { ?taxon wdt:P1843 ?commonname . FILTER ( lang ( ?commonname ) = "[AUTO_LANGUAGE]" ) } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,cs,pl" } } GROUP BY ?taxon ?rank

Query all taxons which are trees


Question: Who are politicians that are citizens of the United States and have either parent or mother being also a politican?

PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT DISTINCT ?item WHERE { ?item wdt:P31 wd:Q5 ; wdt:P27 wd:Q30 ; wdt:P106 wd:Q82955 . { ?item wdt:P22 ?father . ?father wdt:P106 wd:Q82955 . } UNION { ?item wdt:P25 ?mother . ?mother wdt:P106 wd:Q82955 . } }

I'm trying to write a query to find American politicians whose father or mother was also a politician


Question: What are the cities with a population of at least one million people?

PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT DISTINCT ?city WHERE { ?city wdt:P31 / wdt:P279 * wd:Q515 . ?city wdt:P1082 ?population . FILTER ( ?population >= 1000000 ) . }

Names of all cities around the world with a population larger than one million


Question: What are the Australian aerodrome and total number of passengers for the year 2016 (as opposed to just the number for Australian or rest of the world passengers ), ordered by the number of passengers in descending order?

PREFIX pq: <http://www.wikidata.org/prop/qualifier/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?number WHERE { ?item wdt:P31 / wdt:P279 * wd:Q62447 . ?item wdt:P17 wd:Q408 . ?item p:P3872 ?statement . ?statement pq:P585 ?time . ?statement pq:P518 ?applies_to . ?statement ps:P3872 ?number . filter ( year ( ?time ) = 2016 ) filter ( ?applies_to = wd:Q2165236 ) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } order by desc ( ?number )

Patronage of an Australian airport


Question: What are the counts of Byzantinists by their country of citizenship, categorized by gender (male, female, or other)? In other words, for each country, return how many byzantinists are male, female, and other.

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?nLabel ( COUNT ( ?male_ ) AS ?male ) ( COUNT ( ?female_ ) AS ?female ) ( COUNT ( ?other_ ) AS ?other ) WHERE { ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n ; wdt:P21 ?g . bind ( coalesce ( IF ( ?g = wd:Q6581097 , 1 , 1 / 0 ) ) as ?male_ ) bind ( coalesce ( IF ( ?g = wd:Q6581072 , 1 , 1 / 0 ) ) as ?female_ ) bind ( coalesce ( IF ( ?g not in ( wd:Q6581097 , wd:Q6581072 ) , 1 , 1 / 0 ) ) as ?other_ ) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]" . } } GROUP BY ?nLabel ORDER BY ?nLabel

Cross two variables in a table


Question: For each state in Mexico, who is its current state governoer?

PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX ps: <http://www.wikidata.org/prop/statement/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?item ?state WHERE { ?wiki_items p:P1308 ?statement . ?wiki_items wdt:P279 wd:Q17810142 . ?statement ps:P1308 ?item . ?wiki_items p:P1001 ?other_statement . ?other_statement ps:P1001 ?state . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } }

Help simplifying query: Request all officeholders (p:`officeholder (P1308)`) and applies to jurisdiction (p:`applies to jurisdiction (P1001)`) of governors of a mexican state (wdt:`state governor of Mexico (Q17810142)`)