Open main menu

Wikidata:Request a query

Request a query
Fishing in the Wikidata river requires both an idea where to look for fish and a suitable fishing method. If you have the former, this page can help you find the latter.

This is a page where SPARQL 1.1 Query Language (Q32146616) queries can be requested. Please provide feedback if a query is written for you.

For sample queries, see Examples. Property talk pages include also summary queries for these.

For help writing your own queries, or other questions about queries, see Wikidata talk:SPARQL query service/queries.

Help resources about Wikidata Query Service (Q20950365) and SPARQL: Wikidata:SPARQL query service/Wikidata Query Help and Category:SPARQL.

On this page, old discussions are archived. An overview of all archives can be found at this page's archive index. The current archive is located at 2019/02.

Contents

sparqlEdit

se desea que los resultados de una consulta federada, empleando Wikidata y Europeana, sean empleados para alimentar un simple catálogo de imágenes asociadas a las obras de pintores impresionistas y/o expresionistas. Para cada obra, será necesario recopilar, como mínimo, la siguiente información: Nombre del autor Título de la obra Enlace a la imagen  – The preceding unsigned comment was added by 79.144.202.117 (talk • contribs) at 29. 12. 2018, 19:37‎ (UTC).

Using Wikidata only:
#defaultView:ImageGrid
select ?item ?itemLabel ?author ?authorLabel ?image {
  values (?movement) {(wd:Q40415)}
  ?author wdt:P135 ?movement .
  ?item wdt:P170 ?author .
  optional { ?item wdt:P18 ?image }
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!  -- Luitzen (talk) 09:02, 6 February 2019 (UTC)

Black/African-American and LGBT individuals in STEMEdit

In honor of Black History Month, I am hoping to write some biographies on Black/African-American and LGBT people. I mostly focus on members of the STEM community. If there are enough, I was hoping to write about people who are both Black and LGBT that do not already have an article on English Wikipedia. I am also interested if they have a Twitter username. Thank you! Thsmi002 (talk) 16:08, 1 February 2019 (UTC)

@Thsmi002: I think there are lack-of-data issues which will frustrate this query. Example: here are counts of sexual orientation (P91):
SELECT ?sexualityLabel (COUNT(?sexuality) AS ?count)
WHERE {
  ?item wdt:P91 ?sexuality .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by  ?sexualityLabel
Try it!
and ethnic group (P172)
SELECT ?ethnicityLabel (COUNT(?ethnicity) AS ?count)
WHERE {
  ?item wdt:P172 ?ethnicity .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by  ?ethnicityLabel
Try it!
perhaps slightly better for African Americans. So here are AAs with no en.wiki article, showing the number of sitelinks, which might or might not be useful:
SELECT ?item ?itemLabel ?linkcount WHERE {
  ?item wdt:P172 wd:Q49085 .
  FILTER NOT EXISTS {                              # has no en.wikipedia sitelink
    ?wen schema:about ?item .
    ?wen schema:isPartOf <https://en.wikipedia.org/> .
  }
  ?item wdt:P31 wd:Q5 .                            # human
  OPTIONAL {?item wikibase:sitelinks ?linkcount .} # count of sitelinks 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by DESC(?linkcount)
Try it!
Here is other then heterosexual people:
SELECT ?item ?itemLabel ?sexualityLabel ?linkcount WHERE {
  ?item wdt:P91 ?sexuality .
  values ?sexuality {wd:Q592 wd:Q6636 wd:Q6649 wd:Q43200 wd:Q51415 wd:Q255155 wd:Q271534 wd:Q339014 wd:Q724351 wd:Q8354594
}  FILTER NOT EXISTS {                              # has no en.wikipedia sitelink
    ?wen schema:about ?item .
    ?wen schema:isPartOf <https://en.wikipedia.org/> .
  }
  ?item wdt:P31 wd:Q5 .                            # human
  OPTIONAL {?item wikibase:sitelinks ?linkcount .} # count of sitelinks 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by DESC(?linkcount)
Try it!
And the only record which combines these two is Skitzo (Q37022934). Not sure how much help any of that was. There is also w:en:Wikipedia:WikiProject LGBT studies/Missing biographies of nonbinary, trans and intersex people and w:en:Wikipedia:WikiProject Women in Red/Black Lunch Table, both found on the w:en:Wikipedia:WikiProject Women in Red/Redlist index page, which may be of interest. --Tagishsimon (talk) 16:48, 1 February 2019 (UTC)
@Tagishsimon: Thank you for these queries, I appreciate it! I figured there would not be many results, but that it was at least worth checking :) Thsmi002 (talk) 13:47, 7 February 2019 (UTC)

Get family and order of mammal taxa missing in a given languageEdit

Hello! I'm trying to get the family and order of any mammal taxa that is not in a given language.

SELECT DISTINCT ?item ?taxonname ?overLabel WHERE {
  ?item wdt:P31 wd:Q16521.
  ?item wdt:P105 wd:Q7432.
  ?item wdt:P171* wd:Q7377.
  ?item wdt:P225 ?taxonname.
  ?item wdt:P171/wdt:P171 ?over.
  ?article schema:about ?item .
  FILTER NOT EXISTS { ?wen schema:about ?item ; schema:inLanguage "en" }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!

How could I get the family and order without using a very weird wdt:P171/wdt:P171 system? -Theklan (talk) 18:31, 2 February 2019 (UTC)

By using wildcards like this:
SELECT DISTINCT ?item ?taxonname ?familyLabel ?orderLabel WHERE {
  ?item wdt:P31 wd:Q16521 .
  ?item wdt:P105 wd:Q7432 .
  ?item wdt:P225 ?taxonname .
  ?item wdt:P171+ wd:Q7377 .
  ?item wdt:P171+ ?family .
  ?family wdt:P105 wd:Q35409 .
  ?family wdt:P171+ ?order .
  ?order wdt:P105 wd:Q36602 .
  FILTER NOT EXISTS { ?wen schema:about ?item ; schema:inLanguage "en" } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
}
Try it!
Matěj Suchánek (talk) 08:25, 6 February 2019 (UTC)
Interestingly, it doesn't show distinct items if they have more than one possible orders. -Theklan (talk) 09:55, 13 February 2019 (UTC)

Get count of statements for specified propertyEdit

Hello. Please modify this query.

SELECT DISTINCT ?p
WHERE  {  VALUES ?p { # in fact there can be more than 30,000 items
   wd:Q30385394 wd:Q30359318 # two statements P577 (now)
   wd:Q21030593 wd:Q21045381 # exact one statement P577
   wd:Q1305037               # without statement P577
 } }

Try it!

Changed query must return only the items which contain exactly one statement with the property publication date (P577) (i.e. wd:Q21030593 wd:Q21045381 elements). As a result, only the query result variable ?p must be displayed. Thanks. --Renamerr (talk) 22:48, 2 February 2019 (UTC)

@Renamerr: Basically, this:
SELECT ?p { 
  VALUES ?p { # in fact there can be more than 30,000 items
    wd:Q30385394 wd:Q30359318 # two statements P577 (now)
    wd:Q21030593 wd:Q21045381 # exact one statement P577
    wd:Q1305037               # without statement P577
  } 
  ?p wdt:P577 []
} GROUP BY ?p HAVING (COUNT(*) = 1)
Try it!
or
SELECT ?p { 
  VALUES ?p { # in fact there can be more than 30,000 items
    wd:Q30385394 wd:Q30359318 # two statements P577 (now)
    wd:Q21030593 wd:Q21045381 # exact one statement P577
    wd:Q1305037               # without statement P577
  } 
  ?p wdt:P577 ?date1
  FILTER NOT EXISTS {
    ?p wdt:P577 ?date2
    FILTER(?date2 != ?date1)
    }
}
Try it!
-- Luitzen (talk) 20:32, 3 February 2019 (UTC)
@Luitzen: Thank you very much. Best regards, Renamerr (talk) 21:47, 3 February 2019 (UTC) P.S. Feedback. Both of the proposed queries are running fast. For 40000 elements (39985 items found) ≈13000 ms was spent. --Renamerr (talk) 22:08, 3 February 2019 (UTC)

Release date of earliest edition of a bookEdit

Hi,

I need the chronologically earliest publication date (P577) of a literary work (Q7725634). This is what I have so far:

select ?work ?workLabel ?earliestEdition ?earliestEditionReleaseDate {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?work wdt:P31 wd:Q7725634.
  ?work wdt:P747 ?edition. # but only the ?earliestEdition.
  # something, something wdt:P577 and wdt:P577
}

Try it!

Thank you 😅 --Shisma (talk) 19:50, 3 February 2019 (UTC)

@Shisma: The idea is the following:
SELECT DISTINCT ?work ?workLabel ?earliestEdition (year(?earliestEditionReleaseDate) AS ?year) {
  ?work wdt:P31 wd:Q7725634.
  ?work wdt:P747 ?earliestEdition. 
  ?earliestEdition wdt:P577 ?earliestEditionReleaseDate .
  FILTER (!isBLANK(?earliestEditionReleaseDate))
  FILTER NOT EXISTS {
    ?work wdt:P747 ?edition . 
    ?edition wdt:P577 ?editionReleaseDate . 
    FILTER (?editionReleaseDate < ?earliestEditionReleaseDate )
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!  -- Luitzen (talk) 18:39, 5 February 2019 (UTC)
as soon as I replace (year(?earliestEditionReleaseDate) AS ?year) with ?earliestEditionReleaseDate it will find the earliest edition multiple times. Any idea why that is?--Shisma (talk) 20:02, 5 February 2019 (UTC)
The number of results should be the same in both cases. Why multiple? Look into e.g. The Godfather (Q243556) -- Luitzen (talk) 20:41, 5 February 2019 (UTC)

Youngest executed criminalsEdit

Hello, I'd like to get a short list of those executed (exemple : George Stinney (Q1336052) ) when very young. Say, all those executed under 18. Thanks ! Bouzinac (talk) 11:33, 4 February 2019 (UTC)

@Bouzinac: List of candidates:
SELECT ?item ?itemLabel ?age  {
  ?item wdt:P1196 wd:Q8454 . 
# ?item wdt:P1399 [] .
  ?item p:P569 [ a wikibase:BestRank ;
                 psv:P569 [ wikibase:timeValue ?birth;
                            wikibase:timePrecision ?precision_birth ] ] .
  ?item p:P570 [ a wikibase:BestRank ;
                 psv:P570 [ wikibase:timeValue ?death;
                            wikibase:timePrecision ?precision_death ] ] . 
  FILTER (?precision_birth > 8 && ?precision_death > 8) 
  BIND ((?death - ?birth)/365.25 AS ?age) 
  FILTER (?age <= 18.5)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
} ORDER BY ?age
Try it! -- Luitzen (talk) 10:50, 5 February 2019 (UTC)
Very interesting. Thanks! Bouzinac (talk) 12:40, 5 February 2019 (UTC)

Cities names ending en 'ac' ==> time outEdit

#added before 2016-10
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q486972.
  ?item wdt:P17 wd:Q142.
  ?item rdfs:label ?itemLabel.
  ?item wdt:P625 ?coord.
  FILTER((LANG(?itemLabel)) = "fr")
  FILTER(REGEX(?itemLabel, "ac$"))
}

Try it! == timing out...any clue? Thanks ! Bouzinac (talk) 17:02, 4 February 2019 (UTC)

@Bouzinac: The following query is fast and returns more than 90% of results:
SELECT ?item ?itemLabel ?coord  {
  ?item wdt:P31/wdt:P279* wd:Q484170 .
  ?item wdt:P625 ?coord.  
  ?item wdt:P1448 ?itemLabel .
  FILTER(LANG(?itemLabel) = "fr")  
  FILTER(REGEX(?itemLabel, "ac$"))
}
Try it!  -- Luitzen (talk) 21:49, 4 February 2019 (UTC)
Yes, thanks! I'll update the query example Bouzinac (talk) 08:29, 5 February 2019 (UTC)

Federated query to sparql endpoint defined in propertyEdit

This works.

SELECT * WHERE 
{
  wd:Q2013 wdt:P5305 ?sparql_endpoint .
  SERVICE <https://query.wikidata.org/sparql>
  {
  ?a wdt:P31 wd:Q146.
  }
}
LIMIT 1

Try it!

However is it possible to query to some endpoint which address will come from query itself?

Example in pseudocode (doesn't work)

SELECT * WHERE 
{
  wd:Q2013 wdt:P5305 ?sparql_endpoint .
  SERVICE <?sparql_endpoint>
  {
  ?a wdt:P31 wd:Q146.
  }
}
LIMIT 1

Try it!

--Zache (talk) 03:10, 5 February 2019 (UTC)

Answer to myself. It just didnt work with query.wikidata.org, but it did work in Sophox like this:

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX schema: <http://schema.org/>

SELECT * WHERE 
{
  BIND(uri("https://query.wikidata.org/sparql") AS ?sparql_endpoint)
  SERVICE  ?sparql_endpoint
  {
        VALUES ?sparql_services { wd:Q2013 wd:Q234110 }
        ?sparql_services wdt:P5305 ?sparql_endpoint2 .
  }
  SERVICE  ?sparql_endpoint2
  {
      SELECT * WHERE { ?a ?b ?c } LIMIT 1
  }
}

Try it!

--Zache (talk) 04:07, 5 February 2019 (UTC)

@Zache: It seems it had been implemented in Blazegraph (see here), but is not working on Wikidata. -- Luitzen (talk) 08:50, 5 February 2019 (UTC)
Thanks! --Zache (talk) 10:44, 5 February 2019 (UTC)

Twins with different place of birthEdit

I am looking for siblings (connected by sibling (P3373)) with same date of birth (P569) but different place of birth (P19). Steak (talk) 09:38, 5 February 2019 (UTC)

@Steak: Remarkable. You'll get two rows for some pairs; we should also look for Place of Birth being missing on one of the pairs, sometime.
SELECT ?item ?itemLabel ?pob1Label ?sibling ?siblingLabel ?pob2Label 
WHERE 
{
  ?item wdt:P3373 ?sibling.
  ?item wdt:P569 ?dob .
  ?sibling wdt:P569 ?dob .
  ?item wdt:P19 ?pob1 .
  ?sibling wdt:P19 ?pob2 .
  filter (?pob1 != ?pob2) 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it! --Tagishsimon (talk) 09:43, 5 February 2019 (UTC)
Thank you! Didn't expect that much... Steak (talk) 09:46, 5 February 2019 (UTC)
No. Here's 'only one sibling has a place of birth'
SELECT ?item ?itemLabel ?pob1 ?pob1Label ?sibling ?siblingLabel ?pob2Label 
WHERE 
{
  ?item wdt:P3373 ?sibling.
  ?item wdt:P569 ?dob .
  ?sibling wdt:P569 ?dob .
  ?item wdt:P19 ?pob1 .
  filter not exists {?sibling wdt:P19 ?pob2 .}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!
And, shall we call them, unidirectional siblings
SELECT ?item ?itemLabel ?sibling ?siblingLabel  
WHERE 
{
  ?item wdt:P3373 ?sibling.
  ?item wdt:P569 ?dob .
  ?sibling wdt:P569 ?dob .
  filter not exists {?sibling wdt:P3373 ?item .}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it! --Tagishsimon (talk) 10:00, 5 February 2019 (UTC)

Weather station with no closure date OR closure after 1953Edit

I am able to write a query to get the weather stations open in 1953 and that were close afterwards, and another one for stations with no closure date.

Somehow, I am not able to combine the two conditions in one SPARQL query. The result of what I've been able to achieve only shows station with a closure date after 1953 but not those with no closure date (if the quere were successful, Kincardine (Q61039179) should be in the result of the query below). I tried to revert the clauses between the "||" but it didn't change anything.

# Stations d'Ontario actives en 1953 
#defaultView:Map
SELECT ?item ?itemLabel ?coord 
WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1904 .

  ?item wdt:P729 ?service_entry . 
  # service entry is before 1953
  FILTER (?service_entry <= "1953-01-01T00:00:00Z"^^xsd:dateTime) .
  # and closure date not before 1953
  ?item wdt:P3999 ?closureDate .
  FILTER(
    # Closure date is not set
    ?closureDate > "1953-01-01T00:00:00Z"^^xsd:dateTime||  NOT EXISTS { ?item wdt:P3999 [] }     # or closure date is after 1953
  )
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}

Try it!

Could someone help me to have both conditions filtering the result at the same time (one OR the other)?

Thanks, Dirac (talk) 16:03, 5 February 2019 (UTC)

@Dirac: E.g.
# Stations d'Ontario actives en 1953 
#defaultView:Map
SELECT ?item ?itemLabel ?coord 
WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1904 .

  ?item wdt:P729 ?service_entry . 
  # service entry is before 1953
  FILTER (?service_entry <= "1953-01-01T00:00:00Z"^^xsd:dateTime) .
  # and closure date not before 1953
  OPTIONAL { ?item wdt:P3999 ?closureDate }
  FILTER(
    # Closure date is not set
    ?closureDate > "1953-01-01T00:00:00Z"^^xsd:dateTime|| !BOUND(?closureDate)     # or closure date is after 1953
  )
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!
See also https://www.w3.org/TR/sparql11-query/#alternatives. -- Luitzen (talk) 17:31, 5 February 2019 (UTC)

Items with specific property in the radius from the pointEdit

Hey, guys! Can you write me a query to display items with P2788 in a specific km distance from a pre set point? Lets say I will chose a village or town in the Czech republic, than set radius in kilometers and than query will display points in map or settlement names in tab which are in that specific radius. Many thanks.--Juandev (talk) 17:46, 5 February 2019 (UTC)

@Juandev:. Weirdly, as far as I can see, the easting is first and the northing second in the point coordinate. I'm completely used to the northing first, easting second. So watch out for that. This is P2788s within 10km of Kadolec (Q72395). There seem to be lots of them :)
#defaultView:Map
SELECT ?place ?location ?distance ?placeLabel WHERE {
    SERVICE wikibase:around { 
      ?place wdt:P625 ?location . 
      bd:serviceParam wikibase:center "Point(16.141761 49.37474 )"^^geo:wktLiteral .
      bd:serviceParam wikibase:radius "100" . 
      bd:serviceParam wikibase:distance ?distance .
    } 
   ?place wdt:P2788 ?P2788.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it! --Tagishsimon (talk) 18:01, 5 February 2019 (UTC)
Cool. Could I have names of settlements in the table with the links to Wikipedia articles? --Juandev (talk) 19:07, 5 February 2019 (UTC)
@Juandev: I've removed the map default display to give you a table, and provided a couple of columns for the article sitelinks ... depending on what you want to do with this, one or other of the columns miht be better for you; the whole thing might be better in a Listeria page, for all I know. Note that this example is selecting EN labels and en.wiki sitelinks - you can tweak that to other languages as you like.
SELECT ?place ?placeLabel ?location ?distance ?sitelink ?article WHERE {
    SERVICE wikibase:around { 
      ?place wdt:P625 ?location . 
      bd:serviceParam wikibase:center "Point(16.141761 49.37474 )"^^geo:wktLiteral .
      bd:serviceParam wikibase:radius "100" . 
      bd:serviceParam wikibase:distance ?distance .
    } 
   ?place wdt:P2788 ?P2788.
   optional { ?article schema:about ?place ;
                       schema:isPartOf <https://en.wikipedia.org/> . 
              ?sitelink ^schema:name ?article .}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it! --Tagishsimon (talk) 10:13, 6 February 2019 (UTC)
Cool. I am modified it a little bit and here is the code if someone would like to use it (I dont know, how to save it to example queries:
# Czech settlements in radius of a specific distance from the point
# Česká sídla (vesnice, města) v určité vzdálenosti od bodu
SELECT ?place ?location ?centerpointLoc ?placeLabel ?distance ?article ?sitelink WHERE {
   
  wd:Q2180733 wdt:P625 ?centerpointLoc . # wd stays for point (settlement) from which the radius goes - proměnná za wd je položkou (sídlem) dle Wikidat, od kterého se v učité vzdálenosti vypíší sídla
  SERVICE wikibase:around { 
      ?place wdt:P625 ?location . 
      bd:serviceParam wikibase:center ?centerpointLoc .
      bd:serviceParam wikibase:radius "35" . # set number of a diameter in km - číslo urči kilometrickou vzdálenost od bodu
      bd:serviceParam wikibase:distance ?distance .
    } 
   ?place wdt:P2788 ?P2788.
  optional { ?article schema:about ?place ;
                       schema:isPartOf <https://cs.wikipedia.org/> . 
              ?sitelink ^schema:name ?article .}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],cs". }
}
Try it!--Juandev (talk) 21:17, 11 February 2019 (UTC)

Missing labelsEdit

Could you please create the following query?

  • missing label in German an/or English
  • not an instance of Scholary article (Q13442814)
  • at least one Wikipedia article in any language
  • output only the 10 lowest item numbers

Thank you!

-- Hundsrose (talk) 07:00, 6 February 2019 (UTC)

No chances. Try Quarry. -- Luitzen (talk) 09:54, 6 February 2019 (UTC)
@Luitzen: Thanks a lot for your fast reply :)
I will dive into quarry now. I thought my request was similar to some I saw on this page. Could you please go more into detail why mine was problematic or not possible? Were there too many conditions? Is there a specific point which causes trouble? -- Hundsrose (talk) 07:12, 8 February 2019 (UTC)
Hey Hundsrose, the problem with your request is that each of the first three criteria involve *really* large amounts of items, i.e. roughly half of Wikidata or so which then would need to be subsetted. It is way too expensive to evaluate this in a query, particularly if you only want to sort it to output just ten items then. Maybe it would help if you could describe a little more in detail what you plan to do.
Regarding de:Wikipedia:Fragen zur Wikipedia#Quarry: Erste Schritte (Tabellen, Performance): Quarry is an interface to query the regular MediaWiki databases using SQL. All wikis typically have the tables listed at mw:Manual:Database layout, and if you consider involving Wikidata information, you might also be interested in mw:Wikibase/Schema. From my experience, the latter option could be relevant if you want to query very large amounts of terms (labels, descriptions, aliases) of Wikidata, as this is apparently much more efficient in SQL than in SPARQL. —MisterSynergy (talk) 20:22, 10 February 2019 (UTC)
@MisterSynergy: Thanks a lot for the answer. This already helps a lot. The idea behind my request was to get more involved in editing wikidata items. I started to insert missing labels and description in german and english with the "Random item" option in Wikidata. However, these items are very often scholary items I'd prefer not to edit and label/description is already inserted. That's why I tried to build my own customized "Random item" for missing labels in my favourite language. Sorting is not really important for me and limiting was meant to limit the query. Any further recommendations? Thanks a lot for the help. Much appreciated and best regards --Hundsrose (talk) 21:57, 11 February 2019 (UTC)
@Hundsrose: A good approach is to try and limit the scope - so rather than "all items except X", try "items in group Y". For example, here's "programming languages, with no label in German, and some number of Wikipedia articles". Andrew Gray (talk) 22:37, 11 February 2019 (UTC)
SELECT ?item (COUNT(DISTINCT ?article) AS ?count) WHERE
{
  ?item wdt:P31 wd:Q9143.                 # item is a programming language
  FILTER(NOT EXISTS { ?item rdfs:label ?lang_label. FILTER(LANG(?lang_label) = "de") })
                                          # no label in German
  ?article schema:about ?item .  FILTER (SUBSTR(str(?article), 11, 15) = ".wikipedia.org/") .
                                          # has some number of sitelinks which are WP articles
} group by ?item order by ?count
Try it!
@Andrew Gray: Thank you very much. This is exactly what I need. I can customize the where-clause and the language also. Thank you all, you pushed me forward. :) Best regards -- Hundsrose (talk) 07:56, 12 February 2019 (UTC)

All articles from Wikipedia project without descriptionEdit

Hi, maybe I want just too much, but is there a possibility of having a query which will show me all the items linked with Slovak Wikipedia that don't have a description? Thanks for the help, --Luky001 (talk) 18:45, 6 February 2019 (UTC)

@Luky001: Probably not in a single query, but yes if you break the problem down into a series of queries. One key question is, in which language(s) must the item not have a description? EN? SK? Any language?
The basic query is below. There are iirc 312,000 items pointing to sk.wikipedia. Looks like a query checking for no descriptions in any language can handle about 100k at a time. So with judicious use of the OFFSET n and LIMIT n, you can with three or four queries go through all the items. The query below is for offset 200000 limit 100000. You would need to adapt that to cover:
  • limit 100000
  • offset 100000 limit 100000
  • offset 200000 limit 100000
  • offset 300000 limit 20000
SELECT ?item ?itemLabel with {
  select ?article where
    {
      ?article schema:isPartOf <https://sk.wikipedia.org/> .
    } offset 200000 limit 100000 } as %i
where
{
  include %i
  ?article schema:about ?item .
  filter not exists {?item schema:description ?desc .}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!
If, instead, you want to check for no description in a specific language - I use EN as the example here, but you can switch it to any langauge you choose by altering the language code in filter(lang(?desc)="en") - you want:
SELECT ?item ?itemLabel with {
  select ?article where
    {
      ?article schema:isPartOf <https://sk.wikipedia.org/> .
    } offset 200000 limit 100000 } as %i
where
{
  include %i
  ?article schema:about ?item .
  filter not exists {?item schema:description ?desc . filter(lang(?desc)="en") }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!
Finally, if you start getting timeouts, make your increments smaller - e.g. 50k chunks instead of 100k chunks. --Tagishsimon (talk) 19:15, 6 February 2019 (UTC)

Integration of MWAPI to parse categories runs into timeout only by de.wikipediaEdit

I tried to create a query to fetch the categories of the corresponding wikipedia-pages from a set of filtered items via SPARQL. I query all railroad line (Q728937) in Austria (Q40) and look for the Categories of their Wikipedia-Pages.

If i used en.wikipedia.org it works pretty fine (also for different other endpoints: nl.wikipedia, jp.wikipedia, fr.wikipedia)

SELECT ?cat ?title WHERE {
   ?Eisenbahn wdt:P31 wd:Q728937.
   ?Eisenbahn wdt:P17 wd:Q40.
   ?wikiLink schema:isPartOf <https://fr.wikipedia.org/>;
                      schema:name ?title ;
                      schema:about ?Eisenbahn.
   SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Categories" .
     bd:serviceParam wikibase:endpoint "fr.wikipedia.org" .
     bd:serviceParam mwapi:titles ?title .
     ?cat wikibase:apiOutput mwapi:category .
  }
}
LIMIT 300

Try it!

only running against the German Wikipedia it runs in to a timeout. yesterday it succeed for some times with limitations up to 500, but since yesterday afternoon it won't work anymore...

SELECT ?cat ?title WHERE {
   ?Eisenbahn wdt:P31 wd:Q728937.
   ?Eisenbahn wdt:P17 wd:Q40.
   ?wikiLink schema:isPartOf <https://de.wikipedia.org/>;
                      schema:name ?title ;
                      schema:about ?Eisenbahn.
   SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Categories" .
     bd:serviceParam wikibase:endpoint "de.wikipedia.org" .
     bd:serviceParam mwapi:titles ?title .
     ?cat wikibase:apiOutput mwapi:category .
  }
}
LIMIT 30

Try it!

Thanks for some information. --Mfchris84 (talk) 13:12, 7 February 2019 (UTC)

@Mfchris84: I've asked in the project chat: https://www.wikidata.org/wiki/Wikidata:Project_chat#MWAPI_against_de.wikipedia.org
@Mfchris84: It seems it was fixed. -- Luitzen (talk) 09:01, 12 February 2019 (UTC)

Search for genus & species items missing descriptionsEdit

How can I get significantly more than a paltry 2000-3000 results from

SELECT ?rank WHERE {
  ?rank wdt:P105 wd:Q34740. # Q37517=class; Q36602=order; Q35409=family; Q34740=genus; Q7432=species
  FILTER(NOT EXISTS {
    ?rank schema:description ?itemdesc.
    FILTER(LANG(?itemdesc) = "en") # with missing English description
  })
}

Try it!

for genus & species items with empty descriptions? —Tom.Reding (talk) 13:50, 8 February 2019 (UTC)

I'm confused...when I set "LIMIT = 5000" I get either a server error or a timeout... Then when I remove the LIMIT, I get 28,786 results...wtf? —Tom.Reding (talk) 13:58, 8 February 2019 (UTC)
It's very odd. Works fine with LIMIT 5, LIMIT 50, LIMIT 500, timesout or server error at LIMIT 5000, works fine with no limit - 28787 results in 24061 ms. @Smalyshev (WMF), Lucas Werkmeister (WMDE): any thoughts? --Tagishsimon (talk) 17:33, 8 February 2019 (UTC)
Good point! If a query has LIMIT and doesn't have ORDER BY, Blazegraph divides query into smaller parts. Compare execution plans: 1, 2.
It seems that setting … hint:pipelinedHashJoin false can't override this behavior. Just add ORDER BY:
SELECT ?rank WHERE {
  ?rank wdt:P105 wd:Q34740.
  FILTER NOT EXISTS {
    ?rank schema:description ?itemdesc.
    FILTER(LANG(?itemdesc) = "en")
  } 
} ORDER BY ?something LIMIT 29000
Try it! -- Luitzen (talk) 18:20, 8 February 2019 (UTC)
@Tom.Reding: As for species… I'd suggest to divide your query into smaller parts that correspond to classes. Like this.
Example for mammals:
SELECT DISTINCT ?species {
    ?species wdt:P171+ wd:Q7377. 
    ?species wdt:P105 wd:Q7432
    FILTER NOT EXISTS {
        ?species schema:description ?itemdesc
        FILTER(LANG(?itemdesc) = 'en')
    }
}
Try it! Unfortunately, this doesn't work for insects, so divide them into subtaxons etc. -- Luitzen (talk) 11:54, 9 February 2019 (UTC)
@Luitzen: wow, thank you! Those are some high-powered queries - I'm amazed at the utility of '+'. Lots to play with :) —Tom.Reding (talk) 15:32, 9 February 2019 (UTC)

Amount of current US congressmen who have a certain majorEdit

I would like to have a list of university majors and the amount of congressmen/women that have each major. Thanks in advance ; ) ChristianKl❫ 11:47, 9 February 2019 (UTC)

I started doing this query for just any US senators and their academic majors, but those are so sparsely populated that I didn't proceed, the data just doesn't seem to be there.
SELECT ?person ?personLabel ?acaMajorLabel WHERE {
  ?person wdt:P31 wd:Q5.
  ?person wdt:P39 wd:Q13217683.
  ?person p:P69 ?pEdu.
  optional {?pEdu pq:P812 ?acaMajor.}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!--37.201.30.22 21:53, 10 February 2019 (UTC)
Yeah, the "major" qualifier isn't well-populated at all (partly because it's hard to import, I guess). There are just nine for current Senators/Representatives (below) Andrew Gray (talk) 22:04, 10 February 2019 (UTC)
SELECT distinct ?person ?personLabel ?institutionLabel ?acaMajorLabel WHERE {
  ?person wdt:P31 wd:Q5.
  { ?person p:P39 ?positionStatement . ?positionStatement ps:P39 wd:Q13217683. }
  union
  { ?person p:P39 ?positionStatement . ?positionStatement ps:P39 wd:Q13218630. }
  ?person p:P69 ?pEdu. ?pEdu ps:P69 ?institution . ?pEdu pq:P812 ?acaMajor.
  ?positionStatement pq:P2937 wd:Q28227688 . # current term only - comment out for all
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Header of QueryEdit

Hi!. The following query has the title "zzzother": [1] I would like to be able to provide a custom name for the table, i.e. "Members of the 7th Parliament of the 4th Republic of Ghana". Thanks. —M@sssly 03:00, 10 February 2019 (UTC)

@Masssly: Not sure if that's possible, but I've got rid of zzzother, which seemed to result from trying to section the tables based on located in the administrative territorial entity (P131), which was never going to work. There is a header_template parameter, but right now that's still above my pay grade ... if I figure out how to use it - and it might be the solution - I'll let you know. --Tagishsimon (talk) 03:20, 10 February 2019 (UTC)
The page title is odd - the table is a blue-list, not a red-list. Not sure what that's all about. --Tagishsimon (talk) 03:23, 10 February 2019 (UTC)
You might also want to be aware of Wikidata:WikiProject every politician, if you've not come across it. I did a complete treatment on Zambia and as much as I could on Malawi, should you want to talk to anyone about getting a complete representation of the 7th P of the 4th R on wikidata. --Tagishsimon (talk) 04:03, 10 February 2019 (UTC)
Hi @Tagishsimon: I was getting really frustrated with that header, thank you so much for your help. I'm planning a series of Editathons to update Wikidata items about Ghanaian MP's. I would be glad to have a complete treatment of representation of the 7th Parliament of the 4th Republic of Ghana on wikidata. Could you help us with that? —M@sssly 10:01, 10 February 2019 (UTC)
@Masssly: Sure thing. I'll have a look at it in about 12 hours time. I have a CSV of all of the MPs, so its a question of, do we have items for all the constituencies and parties, and then a quick project to add items for MPs we don't have and/or add position statements to items we do have and who are MPS - so, matching names. If I can remember how, I'll set up a Ghana section on Wikidata:WikiProject every politician. To be honest, the biggest risk is that the whole job gets done before your planned editathons - although the CSV I have lacks information on gender, so there will be a job to be done to identify and add that for all records; and I do not have anything on ministerial post-holders, to that will be to do, too. Does that work? It'll be really great to get another African country up & running properly. And of coure, out of it will come a proper redlist of MPs who lack articles. --Tagishsimon (talk) 11:49, 10 February 2019 (UTC)
I do note you have "Editathon at Wikipedia:Madina Institute of Science and Technology (Dates: 2019 February 23, April 27 and May 25)". If you would prefer me not to do most of the work, so that the planned editathon still has work to do, I'm equally happy to hold off - just let me know how you want to play it. --Tagishsimon (talk) 12:00, 10 February 2019 (UTC)
I'm excited at how this is going. I think that there are a lot more statements beside Position held (P39) and their qualifiers, that participants of the events may still get to add. Like you mentioned, gender and ministerial post-holders are potentials candidates. New ideas may come up and so I don't mind if we can get as much of the work done now. So yes, please go ahead. —M@sssly 12:54, 10 February 2019 (UTC)

What is the "inverse" of wikibase:geoLatitudeEdit

If I have a "coordinate value" as a result (node) in a SPARQL query, I can dig further into that node and get stuff like "wikibase:geoLatitude" and "wikibase:geoLongitude". But how do I do the opposite, i.e. how to I "construct" a "value" from variables ?latitude and ?longitude, a "value" that I can BIND to ?coord in order to have it properly displayed in the defaultView Map?

I want to write something like BIND( ?????(?latitude, ?longitude)^^xsd:?????? AS ?coord ) --Larske (talk) 12:31, 11 February 2019 (UTC)

There is mw:Wikibase/Indexing/RDF Dump Format#Globe coordinate which might be helpful. —MisterSynergy (talk) 13:10, 11 February 2019 (UTC)
@Larske:
#defaultView:Map
SELECT * {BIND (STRDT("Point(-0.001475 51.4778111)", geo:wktLiteral) AS ?point)}
Try it!
or
#defaultView:Map
SELECT ?observatory ?point {
  VALUES (?observatory) {(wd:Q192988)}
  ?observatory p:P625/psv:P625 [wikibase:geoLongitude ?longitude; wikibase:geoLatitude ?latitude]
  BIND (
        STRDT(
              CONCAT( 'POINT(', STR(?longitude), ' ', STR(?latitude), ')' ),
              geo:wktLiteral
             )
        AS ?point
       )
}
Try it!  -- Luitzen (talk) 13:47, 11 February 2019 (UTC)
@MisterSynergy, Luitzen: Thank you very much for the pointer and the examples. What about the geoPrecision and geoGlobe, can they be CONCAT-ed together with geoLongitude and geoLatitude in the first parameter, i.e. POINT(), of the STRDT function to give a value for ?point that can be complete and possible to test for an exact match of all four "point components" to values obtainted by psv:P625? Probably not a good idea due to possible rounding errors, but just out of curiosity...
--Larske (talk) 17:46, 11 February 2019 (UTC)
I do not think that you need a full quadruple entity to compare values. You can just compare against the psv:P625 components. For further reading, there are GeoSPARQL (Q5533918) (with sitelinks) and OGC GeoSPARQL - A Geographic Query Language for RDF Data (Q50233318) (with weblinks) available. From what I saw at a glance, there is no GeoSPARQL data type that holds all four values we use here at Wikidata. Please also mind that the wikibase:geoPrecision component is pretty useless right now, as it definition is poor. IMO it is not even worth to even only look at it. —MisterSynergy (talk) 18:20, 11 February 2019 (UTC)

Select items that are plantsEdit

Given a list of QIDs I need to select those that are associated with the plant taxon (Q756). I imagine this is accomplished by recursively evaluating the items 'parent taxon' property but am unsure how to structure such a query.

 – The preceding unsigned comment was added by RDS0601 (talk • contribs) at 19:24, 11 February 2019‎ (UTC).

@RDS0601:
select * { 
  ?plant wdt:P171+ wd:Q756 .
  hint:Prior hint:gearing "forward" 
  } values (?plant) { (wd:Q145992) (wd:Q47128) }
Try it!
See also https://www.w3.org/TR/sparql11-query/#propertypaths -- Luitzen (talk) 19:49, 11 February 2019 (UTC)

results containing english sitelinkEdit

Got a query set up for people whose place of birth is within a country (Australia as an example) and who lack a gender P21] (Australia as an example, borrowed from Tagishsimon)

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P19 ?place.
  ?place wdt:P17 wd:Q408.
  ?item wdt:P31 wd:Q5.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  FILTER(NOT EXISTS { ?item wdt:P21 _:b1. })
}

Try it!

Is there any way to include only the results that have a sitelink to english wikipedia? Thanks! Nat965 (talk) 09:00, 12 February 2019 (UTC)

@Nat965: Sure:
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P19 ?place.
  ?place wdt:P17 wd:Q408.
  ?item wdt:P31 wd:Q5.
  ?article schema:about ?item ;
          schema:isPartOf <https://en.wikipedia.org/> .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  FILTER(NOT EXISTS { ?item wdt:P21 _:b1. })
}
Try it! and you can bung ?article in the select if you want to see it, or add another line ?sitelink ^schema:name ?article . to look at the sitelink. iirc one is the short name, the other a full URL; I forget which is which. --Tagishsimon (talk) 09:23, 12 February 2019 (UTC)
Also, welcome to property paths - the first two lines of the query can be collapsed:
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P19/wdt:P131* wd:Q408.
  ?item wdt:P31 wd:Q5.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  FILTER(NOT EXISTS { ?item wdt:P21 _:b1. })
}
Try it! --Tagishsimon (talk) 14:03, 12 February 2019 (UTC)

Video game genres and OLAC catalogueEdit

Hi,

I want to make a graph of video game genre (Q659563) and outline the ones that are linked to OLAC video game vocabulary (Q60440967) via OLAC video game genre vocabulary (P6352)

I got as far as the following (as well as many many variations) but I don’t seem to be able to get the colours properly… Any help appreciated! Jean-Fred (talk) 17:07, 13 February 2019 (UTC)

SELECT DISTINCT ?genre ?genreLabel ?OLAC ?_subclass_of ?_subclass_ofLabel ?rgb WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?genre wdt:P31 wd:Q659563.
  ?genre wdt:P279 ?_subclass_of.
  #?_subclass_of wdt:P31 wd:Q659563. 
  OPTIONAL { ?genre wdt:P6352 ?OLAC. }
  #OPTIONAL { ?_subclass_of wdt:P6352 ?OLAC. }
  BIND(IF(BOUND(?OLAC),"FFA500","7FFF00") AS ?rgb).
}

Try it!

@Jean-Frédéric: Perhaps you need something like this:
#defaultView:Graph
SELECT DISTINCT ?genre ?genreLabel ?rgb ?OLAC ?_subclass_of ?_subclass_ofLabel {
  ?genre wdt:P31 wd:Q659563.
  OPTIONAL { ?genre wdt:P279 ?_subclass_of. ?_subclass_of wdt:P31 wd:Q659563. }
  OPTIONAL { ?genre wdt:P6352 ?OLAC. }
  BIND(IF(BOUND(?OLAC),"FFA500","7FFF00") AS ?rgb)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!  --Luitzen (talk) 13:02, 14 February 2019 (UTC)
@Luitzen: Thanks, that makes sense! I added one band-aid so that the central node video game (Q7889) would be added to make
#defaultView:Graph
SELECT DISTINCT ?genre ?genreLabel ?rgb ?OLAC ?_subclass_of ?_subclass_ofLabel WHERE {
  ?genre wdt:P31 wd:Q659563.
  VALUES ?gametype { wd:Q659563 wd:Q2249149 }
  OPTIONAL {
    ?genre wdt:P279 ?_subclass_of.
    { ?_subclass_of wdt:P31 wd:Q659563. } UNION {?_subclass_of wdt:P279 wd:Q2249149.}
  }

  OPTIONAL { ?genre wdt:P6352 ?OLAC. }
  BIND(IF(BOUND(?OLAC), "FFA500", "7FFF00") AS ?rgb)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Thanks! Jean-Fred (talk) 13:52, 14 February 2019 (UTC)

Authors who contributed papers to a specific journalEdit

Can someone show me how to create a query to identify people who contributed scholarly article (Q13442814) to Costume (Q35387261) without including all of the individual articles in the query results? I'd like a Listeria list with EN label, EN description, birth/death dates, and field of work. Thanks! - PKM (talk) 00:16, 14 February 2019 (UTC)

@PKM: This is a game of two halves; we need a query to find the items, then a Listeria report to flesh out the details you're after. The query is:
SELECT ?item 
WHERE 
{
  ?article wdt:P1433 wd:Q35387261. # article was published in costume
  ?article wdt:P50 ?item . # here's an author
}
Try it!
and the example Listeria report is at User:Tagishsimon/junk2. The two important things to note are 1) Listeria is driven by whatever you select as the variable ?item - so in this case we make the author the ?item and 2) Listeria's column parameter is the place to set most of your desired columns - they don't need to be referenced in the query if they're a simple property - so in this case, |columns=number:#,label,description,P569:DoB,P570:DoD,P101:field,item:wikidata item is what's wanted. --Tagishsimon (talk) 00:29, 14 February 2019 (UTC)
@Tagishsimon: thanks, that's perfect! I've copied the report over to one of my user pages. - PKM (talk) 00:59, 14 February 2019 (UTC)
@Tagishsimon, PKM: Just a comment about authors. Not all authors are given as property author (P50) of the article object since they don't have a Wikidata object. Some are given as author name string (P2093) and have none of the wanted properties in Wikidata. They may nevertheless be of interest to be listed by their names.
SELECT DISTINCT ?item 
WHERE 
{
  ?article wdt:P1433 wd:Q35387261. # article was published in costume
  ?article wdt:P2093 ?item . # here's an author (without a Wikidata object)
}
ORDER BY ?item
Try it!
This query gives 397 distinct author names. The query with P50 only gives 76 distinct author objects.
Maybe it is possible to combine these two queries into one to get also the authors without Wikidata object as rows, containing only the author names, in the Listeria.
--Larske (talk) 01:22, 14 February 2019 (UTC)
@Larske: Thanks. I am actually working on the items with "author name string" through Scholia - the remaining "author name string" authors have only 1 or 2 contributions and are a bit harder to track down. I've matched all of the authors with 3 or more contributions. - PKM (talk) 01:33, 14 February 2019 (UTC)
Still, it's instructive to look at how the two might be combined. It's a bit of a pest, tbh. The SPARQL is something like this:
SELECT ?item ?author ?authorQID ?dob ?dod ?field ?description with 
{ 
  select (sample(?it) as ?item) ?author ?description (sample(?aut3) as ?authorQID) (group_concat(distinct ?fiel;separator=", ") as ?field) ?dob ?dod
WHERE 
{
  ?it wdt:P1433 wd:Q35387261. # article was published in costume
  ?it wdt:P50 ?aut . # here's an author
  bind(strafter(str(?aut),"http://www.wikidata.org/entity/") as ?aut2)
  BIND (CONCAT ("[http://www.wikidata.org/entity/", ?aut2, " ", ?aut2,"]") as ?aut3) .
  optional {?aut wdt:P569 ?dob .}
  optional {?aut wdt:P570 ?dod .}
  optional {?aut wdt:P101 ?fi . ?fi rdfs:label ?fiel . filter(lang(?fiel)="en")} 
  optional {?aut rdfs:label ?author .  filter(lang(?author)="en")} 
  optional {?aut schema:description ?description .  filter(lang(?description)="en")} 
} group by ?author ?dob ?dod ?description
} as %i with 
{ 
  select (sample(?it) as ?item) ?author ?authorQID ?field ?dob ?dod ?description WHERE 
  {
    ?it wdt:P1433 wd:Q35387261. # article was published in costume
    ?it wdt:P2093 ?author . # here's an author (without a Wikidata object)
  } group by ?author ?authorQID ?field ?dob ?dod ?description
} as %j
where
{
{  include %i}
          UNION
{  include %j }
}
Try it!
and the Listeria is something like User:Tagishsimon/junk2 - and even then, we lose the blue & redlinks to wikipedia articles ... we might get them back with even more tinkering, but I'm not inclined to do much more on it. --Tagishsimon (talk) 02:24, 14 February 2019 (UTC)
Perhaps this is better:
SELECT ?item ?author ?authorQID ?dob ?dod ?field ?description with 
{ 
  SELECT ?item ?author ?description
WHERE 
{
  ?article wdt:P1433 wd:Q35387261. # article was published in costume
  ?article wdt:P50 ?item . # here's an author
  optional {?item rdfs:label ?author .  filter(lang(?author)="en")} 
  optional {?item schema:description ?description .  filter(lang(?description)="en")} 

}
} as %i with 
{ 
  select (sample(?it) as ?item) ?author ?description WHERE 
  {
    ?it wdt:P1433 wd:Q35387261. # article was published in costume
    ?it wdt:P2093 ?author . # here's an author (without a Wikidata object)
  } group by ?author ?description
} as %j
where
{
{  include %i}
          UNION
{  include %j }
}
Try it!
and User:Tagishsimon/junk2 for the Listeria. --Tagishsimon (talk) 07:30, 14 February 2019 (UTC)
At least that mostly pointless exercise led me to three items for obituaries in which we mistakenly listed the deceased as authors; now fixed. --Tagishsimon (talk) 08:03, 14 February 2019 (UTC)

need help with a queryEdit

I am trying to get a query with properties of items that have sitelings pointing to pages on c:Category:Commons_licensing_help_by_country. I come up with :

SELECT ?item ?itemLabel ?instanceLabel ?countryLabel ?jurisdictionLabel ?subjectLabel  {
  SERVICE wikibase:mwapi {
	 bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
     bd:serviceParam mwapi:gcmtitle "Category:Commons_licensing_help_by_country" .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmtype "page" .
     bd:serviceParam mwapi:gcmlimit "max" .
     bd:serviceParam mwapi:gcmsort "timestamp" .
     bd:serviceParam mwapi:gcmdir "descending" .
     ?item wikibase:apiOutput mwapi:title  .
  }
  #?commonsSitelink schema:about ?item; schema:isPartOf <https://commons.wikimedia.org/>; schema:name ?sitelink_label .
  Optional { ?item wdt:P31 ?instance. }
  Optional { ?item wdt:P17 ?country. }
  Optional { ?item wdt:P1001 ?jurisdiction. }
  Optional { ?item wdt:P921 ?subject. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

Try it!

But did not get it to work yet. can someone help? --Jarekt (talk) 19:52, 14 February 2019 (UTC)

I can get close, but no cigar. First, consider the query:
SELECT ?sitelink ?article ?item where {
  values ?sitelink  {"Commons:Copyright rules by territory/Armenia"@en}
  ?sitelink ^schema:name ?article .
  ?article schema:about ?item ;
           schema:isPartOf <https://commons.wikimedia.org/> .
}
Try it!
Clearly that's working; we're finding the ?item starting from a ?sitelink string. But applying that approach in your query still fails for me. Consider a second query, which seems to suggest that I'm generating a ?sitelink akin to that in the above query
SELECT ?commonsTitle ?sitelink ?item ?itemLabel ?instanceLabel ?countryLabel ?jurisdictionLabel ?subjectLabel  {
  SERVICE wikibase:mwapi {
	 bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
     bd:serviceParam mwapi:gcmtitle "Category:Commons_licensing_help_by_country" .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmtype "page" .
     bd:serviceParam mwapi:gcmlimit "max" .
     bd:serviceParam mwapi:gcmsort "timestamp" .
     bd:serviceParam mwapi:gcmdir "descending" .
     ?commonsTitle wikibase:apiOutput mwapi:title  .
  }
  hint:Query hint:optimizer "None" .
  bind(concat("\"",?commonsTitle,"\"","@en") as ?sitelink)
#  ?sitelink ^schema:name ?article . 
#  ?article schema:about ?item ;
#           schema:isPartOf <https://commons.wikimedia.org/> .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!
But enable the commented-out rows, and nothing's found. So, sorry about that. I join the queue in wanting to know where it all went wrong. --Tagishsimon (talk) 22:25, 14 February 2019 (UTC)
The query
SELECT ?sitelink ?item ?itemLabel ?instanceLabel ?countryLabel ?jurisdictionLabel ?subjectLabel where {
  FILTER(STRSTARTS(STR(?sitelink), "Commons:Copyright rules by territory/")) .
  ?sitelink ^schema:name ?article .
  ?article schema:about ?item ;
           schema:isPartOf <https://commons.wikimedia.org/> .
  Optional { ?item wdt:P31 ?instance. }
  Optional { ?item wdt:P17 ?country. }
  Optional { ?item wdt:P1001 ?jurisdiction. }
  Optional { ?item wdt:P921 ?subject. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!  has the same final results. --Jarekt (talk) 04:21, 15 February 2019 (UTC)
@Jarekt:
select ?item ?itemLabel ?instanceLabel ?jurisdictionLabel ?subjectLabel  {
  service wikibase:mwapi {
	 bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
     bd:serviceParam mwapi:gcmtitle "Category:Commons_licensing_help_by_country" .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmtype "page" .
     bd:serviceParam mwapi:gcmlimit "max" .
     bd:serviceParam mwapi:gcmsort "timestamp" .
     bd:serviceParam mwapi:gcmdir "descending" .
     ?item wikibase:apiOutputItem mwapi:item  .
  }
  filter(bound(?item)) .
  ?commonsSitelink schema:about ?item;
                   schema:isPartOf <https://commons.wikimedia.org/>;
                   schema:name ?sitelink_label .
  optional { ?item wdt:P31 ?instance. }
  optional { ?item wdt:P17 ?country. }
  optional { ?item wdt:P1001 ?jurisdiction. }
  optional { ?item wdt:P921 ?subject. }
  service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} -- [[User:Luitzen|Luitzen]] ([[User talk:Luitzen|<span class="signature-talk">talk</span>]]) 12:46, 17 February 2019 (UTC)
Try it!

Display date of birthEdit

I have made a query to find catalan centenarians alive in ca.wikipedia.org:

SELECT ?s ?desc WHERE {
  ?s wdt:P31 wd:Q5.
  ?s wdt:P569 ?birth.
  ?s wdt:P19 ?place.
  ?place (wdt:P131*/wdt:P706*) wd:Q5705.
  MINUS { ?s wdt:P570 _:b5. }
  ?s rdfs:label ?desc.
  ?article schema:about ?s.
  ?article schema:inLanguage "ca".
  FILTER((?birth > "1898-01-01"^^xsd:dateTime) && (?birth < "1918-01-01"^^xsd:dateTime))
  FILTER((LANG(?desc)) = "ca")
}
GROUP BY ?s ?desc
LIMIT 100

Try it!

Could somebody help me displaying on a third column their date of birth?

Thanks in advance! Paucabot (talk) 21:19, 14 February 2019 (UTC)

@Paucabot: Not quite sure where you're going with this, Paucabot. There's a lot of cruft in your query, such as ?place and ?article, and the group statement. Without starting surgery on any of that, a minimal thing to do is as shown below. Note, however, that the query as it stands is not concerning itself with date precision. Dates in wikidata can be stored to day precision, or to month, year, decade, etc. Where a person's DoB is specified only to the year, you'll get a 1 January date, which can be misleading.
SELECT ?s ?desc ?birth WHERE {
  ?s wdt:P31 wd:Q5.
  ?s wdt:P569 ?birth.
  ?s wdt:P19 ?place.
  ?place (wdt:P131*/wdt:P706*) wd:Q5705.
  MINUS { ?s wdt:P570 _:b5. }
  ?s rdfs:label ?desc.
  ?article schema:about ?s.
  ?article schema:inLanguage "ca".
  FILTER((?birth > "1898-01-01"^^xsd:dateTime) && (?birth < "1918-01-01"^^xsd:dateTime))
  FILTER((LANG(?desc)) = "ca")
}
GROUP BY ?s ?desc ?birth 
LIMIT 100
Try it!
If you want to deal with the precision issue, then something like this is the way to go (albeit even this only sorts things out to precision=year, and will get precisions of decade, century or millenium wrong)
SELECT ?s ?desc ?dob WHERE {
  ?s wdt:P31 wd:Q5.
#  ?s wdt:P569 ?birth.
  ?s  p:P569/psv:P569 [wikibase:timePrecision ?precision; wikibase:timeValue ?birth]
  bind(if(?precision=11,?birth,if(?precision=10,concat(month(?birth)," ",year(?birth)),year(?birth))) as ?dob)                
  ?s wdt:P19 ?place.
  ?place (wdt:P131*/wdt:P706*) wd:Q5705.
  MINUS { ?s wdt:P570 _:b5. }
  ?s rdfs:label ?desc.
  ?article schema:about ?s.
  ?article schema:inLanguage "ca".
  FILTER((?birth > "1898-01-01"^^xsd:dateTime) && (?birth < "1918-01-01"^^xsd:dateTime))
  FILTER((LANG(?desc)) = "ca")
}
GROUP BY ?s ?desc ?dob 
LIMIT 100
Try it! --Tagishsimon (talk) 22:38, 14 February 2019 (UTC)
Thanks, Tagishsimon (talkcontribslogs). The query is crufty simply because I don't know a lot of SPARQL and I make queries using parts of other queries (Frankenstein-style). Furthermore, my original query had no precision time handling because simply I didn't know how to do it. Thanks again. Paucabot (talk) 22:48, 14 February 2019 (UTC)
@Paucabot: Yup, me too - the Frankenstein thing. A very good way to learn. I just didn't want to de-cruft it in case you had plans. Examining the cruft more carefully reveals most of it to be useful; the requirement 'must have a Catalan label' /might/ exclude some otherwise valid oldsters, and the group by is not doing anything.
SELECT ?s ?desc ?dob WHERE {
  ?s wdt:P31 wd:Q5.                           # must be human
  ?s  p:P569/psv:P569 [wikibase:timePrecision ?precision; wikibase:timeValue ?birth]
  bind(if(?precision=11,?birth,if(?precision=10,concat(month(?birth)," ",year(?birth)),year(?birth))) as ?dob)                
  ?s wdt:P19 ?place.                         # must have a place of birth
  ?place (wdt:P131*/wdt:P706*) wd:Q5705.     # place of birth must be located within or on Catelonia
  MINUS { ?s wdt:P570 _:b5. }                # must be alive - no date of death
  ?s rdfs:label ?desc.                       # must have a label ...
  FILTER((LANG(?desc)) = "ca")               # label must be in Catalan
  ?article schema:about ?s.                  # must have a sitelink
  ?article schema:inLanguage "ca".           # sitelink must be (by inference) to the Catalan wikipedia
  FILTER((?birth > "1898-01-01"^^xsd:dateTime) && (?birth < "1918-01-01"^^xsd:dateTime))
}
GROUP BY ?s ?desc ?dob                       # right now the group by serves no purpose whatsoever - there are to aggregates in the select
LIMIT 100                                    # obvs, only give me 100 results
Try it! --Tagishsimon (talk) 23:05, 14 February 2019 (UTC)
@Paucabot, Tagishsimon: The issue with time values stated with precision less than 9 (year) that you mention is quite a big problem if you ask me. There does not seem to be a common understanding on how to use and how interprete them and the Wikidata user interface is still confusing in many languages.
See Help_talk:Dates#Clarifying_“century”-_and_“millennium”-precision_dates where there is a discussion on "logic versus established norms". My conclusion is that you should be very careful and not thrust time values in Wikidata stated with less than year precision without investigating them.
In the following query, a modification of the above query, I have choosen to include, in the FILTER clause, also objects where date of birth (P569) is given with a precision less than 9, as they will have to be manually investigated.
SELECT ?s ?desc ?dob ?dobvalue WHERE {
  ?s wdt:P31 wd:Q5.                           # must be human
  ?s  p:P569/psv:P569 [wikibase:timePrecision ?precision; wikibase:timeValue ?birth] .
  ?s  p:P569/ps:P569 ?dobvalue .
  bind(if(?precision=11,?birth,if(?precision=10,concat(month(?birth)," ",year(?birth)),if(?precision<9,concat(STR(?birth),' precision=',STR(?precision)),year(?birth)))) as ?dob)                
  ?s wdt:P19 ?place.                         # must have a place of birth
  ?place (wdt:P131*/wdt:P706*) wd:Q5705.     # place of birth must be located within or on Catelonia
  MINUS { ?s wdt:P570 _:b5. }                # must be alive - no date of death
  ?s rdfs:label ?desc.                       # must have a label ...
  FILTER((LANG(?desc)) = "ca")               # label must be in Catalan
  ?article schema:about ?s.                  # must have a sitelink
  ?article schema:inLanguage "ca".           # sitelink must be (by inference) to the Catalan wikipedia
  FILTER((?birth > "1898-01-01"^^xsd:dateTime) && (?birth < "1918-01-01"^^xsd:dateTime)|| ?precision<9 )
}
 GROUP BY ?s ?desc ?dob ?dobvalue            # right now the group by serves no purpose whatsoever - there are to aggregates in the select
ORDER BY ?dobvalue
# LIMIT 100                                    # obvs, only give me 100 results
Try it!
Just an example to show the problem. Time values "1900-01-01T00:00:00Z" is displayed as "19. century" on the item page (English) whereas "1901-01-01T00:00:00Z" is displayed as "20. century". In the result of the above query you will find several examples of both.
A date of birth (P569) with the value ("1901-01-01T00:00:00Z"), and precision=7, has been used for both Miquel Curet i Roure (Q20005978) (see diff) and Teresa Font (Q21075432) (see diff), but from the Wikipedia articles it seems like the first of them was active around 1880 whereas the second of them was active from around 1976. They are definitely, despite having the same value for date of birth (P569) in Wikidata, not born in the same "century".
--Larske (talk) 08:58, 15 February 2019 (UTC)

Title or labelEdit

Hello. I want to find all items that have:

1) at the title of the article to elwiki the word ΠΓΔΜ

or

2) at the el label of the item the word ΠΓΔΜ.

Xaris333 (talk) 16:23, 15 February 2019 (UTC)

HTH: https://mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Examples -- Luitzen (talk) 16:57, 16 February 2019 (UTC)

Show only highest territorial levelEdit

Hello, how to show only highest {P|131}} ? I work on this list and I do not wish to read city X, county X but only Province X of Canada as of P.131.. :

PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?airport ?airportLabel (SAMPLE(?coord) AS ?coord) ?ICAO ?IATA (SAMPLE(?Local_Code) AS ?Local_Code)  ?localisation_administrativeLabel WHERE {
?airport (wdt:P31/wdt:P279*) wd:Q62447.
?airport wdt:P17 wd:Q16.
MINUS { ?airport wdt:P576 _:b2. }
MINUS { ?airport wdt:P582 _:b3. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q1311670. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q7373622. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q502074. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q2265915. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q44665966. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q782667. }
MINUS { ?airport rdf:type wdno:P17. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,[AUTO_LANGUAGE]". }
OPTIONAL { ?airport wdt:P625 ?coord. }
OPTIONAL { ?airport wdt:P239 ?ICAO. }
OPTIONAL { ?airport wdt:P238 ?IATA. }
OPTIONAL { ?airport wdt:P5699 ?Local_Code. }
OPTIONAL { ?airport wdt:P131* ?localisation_administrative. }
{?localisation_administrative wdt:P31 wd:Q2879.}
}
GROUP BY ?airport ?airportLabel ?ICAO ?IATA ?localisation_administrative ?localisation_administrativeLabel
ORDER BY ?coord

Try it!

Thanks ! Bouzinac (talk) 21:45, 16 February 2019 (UTC)

Ok, I think it was OPTIONAL { ?airport wdt:P131/ wd:Q2879* ?localisation_administrative. } Bouzinac (talk) 22:34, 16 February 2019 (UTC)
Edit conflicted, but here's my answer anyway :-) A problem here is that Ontario is an instance of province of Canada (Q11828004), which is a subclass of province or territory of Canada (Q2879). So P31:Q2879 won't match any items at all - you need to add an extra P279 line to match a province/territory.
You also need to bring this bit inside the overall P131 optional clause, but once you've done that it works correctly. It shows the top-level admin area (if one exists). If it has a P131 but that doesn't link into a chain going up to a province/territory, then it's blank. eg/ Niagara Central Airport (Q94904) has a P131 but it doesn't have a complete chain up to Ontario. Andrew Gray (talk) 22:35, 16 February 2019 (UTC)
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?airport ?airportLabel (SAMPLE(?coord) AS ?coord) ?ICAO ?IATA (SAMPLE(?Local_Code) AS ?Local_Code)  ?localisation_administrativeLabel WHERE {
?airport (wdt:P31/wdt:P279*) wd:Q62447.
?airport wdt:P17 wd:Q16.
MINUS { ?airport wdt:P576 _:b2. }
MINUS { ?airport wdt:P582 _:b3. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q1311670. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q7373622. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q502074. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q2265915. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q44665966. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q782667. }
MINUS { ?airport rdf:type wdno:P17. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,[AUTO_LANGUAGE]". }
OPTIONAL { ?airport wdt:P625 ?coord. }
OPTIONAL { ?airport wdt:P239 ?ICAO. }
OPTIONAL { ?airport wdt:P238 ?IATA. }
OPTIONAL { ?airport wdt:P5699 ?Local_Code. }
OPTIONAL { ?airport wdt:P131* ?localisation_administrative.
           ?localisation_administrative wdt:P31 ?type .
           ?type wdt:P279 wd:Q2879. }
}
GROUP BY ?airport ?airportLabel ?ICAO ?IATA ?localisation_administrative ?localisation_administrativeLabel
ORDER BY ?coord
Try it!
@Bouzinac: looking at these two queries, your OPTIONAL { ?airport wdt:P131/ wd:Q2879* ?localisation_administrative. } doesn't quite seem to work as expected - it returns all the P131 values, regardless of whether they're a town or a province. So Niagara Central Airport (Q94904) has one value (not a province) and Bamfield Water Aerodrome (Q338950) has two (one the province, one the town). I'm not quite sure how the / syntax works though so I can't see why. Andrew Gray (talk) 22:41, 16 February 2019 (UTC)
Hi there, thank you, I buy the OPTIONAL { ?airport wdt:P131* ?localisation_administrative.
          ?localisation_administrative wdt:P31 ?type .
          ?type wdt:P279 wd:Q2879. } The data is often poor on obscure airports… So data is not clean :/ Bouzinac (talk) 23:03, 16 February 2019 (UTC)

Get names and license of all Linux media playersEdit

I can't wrap my head around how to get all players in "Linux media players" category (https://www.wikidata.org/wiki/Q8591688) and show their name and license. But this gets the data from `dbpedia`, not `wikidata`, and some players like https://en.wikipedia.org/wiki/MusikCube are missing from the output.

PREFIX dbc: <http://dbpedia.org/resource/Category:>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>

SELECT ?wsubjectLabel ?licenseName WHERE {
  SERVICE <http://dbpedia.org/sparql> {
    ?subject dct:subject dbc:Linux_media_players.
    ?subject owl:sameAs ?wsubject.
    ?subject dbo:license ?license.
    ?license dbp:name ?licenseName.
    FILTER(STRSTARTS(STR(?wsubject), "http://www.wikidata.org"))
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Query

--Techtonik (talk) 01:03, 17 February 2019 (UTC)

@Techtonik: Like this? —
prefix encat: <https://en.wikipedia.org/wiki/Category:>
select distinct ?itemLabel ?licenseLabel {
  service <https://query.wikidata.org/bigdata/namespace/categories/sparql> {
    ?s mediawiki:isInCategory* encat:Linux_media_players ;
       rdfs:label ?label .
  }
  bind (concat("Category:", ?label) as ?title)
  service wikibase:mwapi {
     bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "en.wikipedia.org" .
     bd:serviceParam mwapi:gcmtitle ?title .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmprop "ids" .
     bd:serviceParam mwapi:gcmlimit "max" .
     ?ns wikibase:apiOutput "@ns" .
     ?item wikibase:apiOutputItem mwapi:item .
  }
  filter(bound(?item) && ?ns = "0")
  optional {?item wdt:P275 ?license} 
  service wikibase:label {bd:serviceParam wikibase:language "en"}
}
Try it! -- Luitzen (talk) 12:34, 17 February 2019 (UTC)

Video games with a Steam Application ID imported from PCGamingWikiEdit

How would I go about creating a query that can find all the items with a Steam Application ID (P1733) and the "reference" for that property set to imported from Wikimedia project (P143) PCGamingWiki (Q17013880)?

For example, this item has a Steam Application ID with this reference: Terminal Velocity (Q955289). There are at least a dozen others I've seen, but I didn't keep track of what items had it, so this is the only one I'm able to link to as an example.

The reason I want this is because I'd like to find all the items with data imported from PCGamingWiki that don't have a PCGamingWiki ID (P6337), as that'd be an easy way to find holes in our data. Also I'm just curious :D

Thanks for the help! Nicereddy (talk) 20:01, 17 February 2019 (UTC)

@Nicereddy: This, I think
SELECT ?item ?itemLabel 
WHERE 
{
  ?item p:P1733 [ ps:P1733 ?steam_ID ; prov:wasDerivedFrom [pr:P143 wd:Q17013880 ] ].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?itemLabel
Try it! --Tagishsimon (talk) 20:06, 17 February 2019 (UTC)
Awesome, that looks right to me. Thanks! Nicereddy (talk) 20:08, 17 February 2019 (UTC)
@Nicereddy: This may also help - answers the question "I'd like to find all the items with data imported from PCGamingWiki that don't have a PCGamingWiki ID (P6337)"
SELECT ?item ?itemLabel 
WHERE 
{
  ?item p:P1733 [ ps:P1733 ?steam_ID ; prov:wasDerivedFrom [pr:P143 wd:Q17013880 ] ].
  filter not exists {?item wdt:P6337 [] . } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?itemLabel
Try it! --Tagishsimon (talk) 20:09, 17 February 2019 (UTC)

Isolate attributes starting with a list of 1200 namesEdit

Hi there,

For a datavizualisation on the subject of famous people whom obtnained their french nationality after they where born, i wish to fetch a certain quantity of data, for 1200 entries : name, occupation, date of birth, country of birth, image, biography, etc. Is it possible to query this ? I don't get much of SPARQL if someone could enlight me on the process.

Thanks dear Wikipedians.