Wikidata:Request a query
Shortcuts: WD:RAQ, w.wiki/LX
Request a query This is a page where SPARQL queries [Q114898838] can be requested. Please provide feedback if a query is written for you. You can also request help to rewrite queries that don't work anymore, due to the WDQS graph split. For sample queries, see Examples and Help:Dataset sizing. 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 and Wikidata:SPARQL query service/query optimization. Help resources about Wikidata Query Service (Q20950365) and SPARQL: Wikidata:SPARQL query service/Wikidata Query Help and Category:SPARQL. To report an issue about the Query Service (interface, results views, export...) please see Wikidata:Contact the development team/Query Service and search. |
| 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 2025/12. |
SpBot archives all sections tagged with {{Section resolved|1=~~~~}} after 2 days.
|
Emma Award winners
[edit]Hello! I was looking at queries for musicians and could not figure out how to find musicians that have won a certain award, e.g.
- Emma Award (Q1337975),
- Emma Award for Album of the Year (Q133280007),
- Emma Award for Artist of the Year (Q133279994),
- Emma Award for Band of the Year (Q115916994)
- Emma Award for Female Artist of the Year (Q56400703)
- Emma Award for Male Artist of the Year (Q56400761)
- Emma Award for Song of the Year (Q133287619)
Cheers, Jjanhone (talk) 09:22, 10 November 2025 (UTC)
- Moi! Saatuja palkintoja varten on ominaisuus award received (P166). Yksittäisen palkinnon saajat pystyy hakemaan näin:
- Try it!
SELECT ?item ?itemLabel WHERE { ?item wdt:P166 wd:Q115916994. # saanut vuoden yhtyeen Emma-palkinnon SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- Yksittäisissä palkintoluokissa (esim. vuoden albumin Emma-palkinto) näyttäisi löytyvän aina esitys part of (P361), joka kertoo mihin laajempaa palkintoryhmään se kuuluu (esim. Emma-palkinto). Tätä hyödyntymällä voi hakea palkintoryhmän kaikkien palkintoluokkien saajat kerralla:
- Try it!
SELECT ?item ?itemLabel ?award ?awardLabel WHERE { ?item wdt:P166 ?award. # saanut palkinnon ?award wdt:P361 wd:Q1337975. # palkinto on osa Emma-palkintoa SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- –Samoasambia ✎ 10:34, 10 November 2025 (UTC)
- Paljon kiitoksia, olipas ylellistä saada vastaus suomeksi. :) Pitäisikö näitä kyselyitä linkittää tuohon yllä mainitsemaani sivuun? Jjanhone (talk) 16:35, 10 November 2025 (UTC)
- @Jjanhone: Pahoittelut, unohdin vastata tähän! Tuo Template:Generic queries for musicians tulostuu automaattisesti Wikidata-kohteiden keskustelusivuille silloin, kun henkilön ammatiksi on merkitty muusikko (tai jokin sen alaluokista). Palkinnot on merkitty yksittäisten muusikkojen kohteisiin, joten tavallaan tästä kyselystä ei olisi siinä yhteydessä hirveästi hyötyä, koska palkintotiedot löytyvät itse kohteesta. Yksi työkalu mistä on kuitenkin hyötyä on relateditems-pienoisohjelma. Sen avulla pystyy nopeasti katsomaan käänteisiä esityksiä, eli minkä muiden kohteiden ominaisuuksissa tiettyä Wikidata-kohdetta käytään. Samoasambia ✎ 20:31, 17 November 2025 (UTC)
- Huh! En ole hoksannut katsoa noit Talk-sivuja, koska ovat punaisia. Mutta näköjään niissä on silti sisältöä. Ja Gadgettejakaan en ollut tajunnut vielä tutkia, mutta otin rohkeasti käyttöön kaikki kerralla. :D Jjanhone (talk) 13:02, 18 November 2025 (UTC)
- @Jjanhone: Pahoittelut, unohdin vastata tähän! Tuo Template:Generic queries for musicians tulostuu automaattisesti Wikidata-kohteiden keskustelusivuille silloin, kun henkilön ammatiksi on merkitty muusikko (tai jokin sen alaluokista). Palkinnot on merkitty yksittäisten muusikkojen kohteisiin, joten tavallaan tästä kyselystä ei olisi siinä yhteydessä hirveästi hyötyä, koska palkintotiedot löytyvät itse kohteesta. Yksi työkalu mistä on kuitenkin hyötyä on relateditems-pienoisohjelma. Sen avulla pystyy nopeasti katsomaan käänteisiä esityksiä, eli minkä muiden kohteiden ominaisuuksissa tiettyä Wikidata-kohdetta käytään. Samoasambia ✎ 20:31, 17 November 2025 (UTC)
- Paljon kiitoksia, olipas ylellistä saada vastaus suomeksi. :) Pitäisikö näitä kyselyitä linkittää tuohon yllä mainitsemaani sivuun? Jjanhone (talk) 16:35, 10 November 2025 (UTC)
Adding structured data to Commons via Quickstatements
[edit]No idea, if this is possible. Let's stay in the Commons category badminton (where I am familiar with). Aim: Add structured data via quickstatements for DEPICTS, CREATED DURING and SIGNIFICANT EVENT. Take the last two statements from the deepest subcategory under Category:Badminton competitions. Take DEPICTS from the deepest subcategory under Category:Badminton people. Example: File:Internationale badmintonwedstrijden in Duinwijckhal Haarlem Spelmoment, Bestanddeelnr 923-2557.jpg needs to add DEPICTS Alan Parsons and CREATED DURING 1970 Dutch Open Badminton Championships. Florentyna (talk) 21:44, 11 November 2025 (UTC)
- hi @Florentyna i think for add depict you can create campaign and use category or subcategory for track picture with https://isa.toolforge.org/ and for adding CREATED DURING and SIGNIFICANT EVENT i have no idea.
- -- Empat Tilda (talk) 09:07, 21 November 2025 (UTC)
- @Florentyna Hi. If You want to add structured data on Commons (for some files, maybe whole category), but Quickstatements is not must-have – check usage of Cat-a-lot (for choosing files to edit – You can choose all in category, if You wish, turned on Gadgets) in combo with ACDC tool (where You can set properties with values for currently chosen files with Cat-a-lot and batch save; also Gadgets, full nae of it is Add to Commons / Descriptive Claims). QS v3 – have no option to edit structured data on Commons (because Wikibase REST API limitations). QS v2 – there is some possibility. regards, Piastu (talk) 10:07, 28 November 2025 (UTC)
Interwikied articles
[edit]The most interwikied article that does not have a Norwegian Bokmål article. Johshh (talk) 11:03, 15 November 2025 (UTC)
- Not that much (with more that 80 sitelinks) ! author TomT0m / talk page 13:21, 15 November 2025 (UTC)Try it!
SELECT ?item ?itemLabel ?st WHERE { { SELECT ?item ?st WHERE { ?item wikibase:sitelinks ?st. hint:Prior hint:rangeSafe "true"^^xsd:boolean. FILTER(?st > 80 ) MINUS { ?article schema:isPartOf <https://no.wikipedia.org/>; schema:about ?item. } MINUS { ?item (wdt:P31/(wdt:P279*)) wd:Q17379835. } } # ORDER BY DESC (?st) } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],no,mul,en". } } order by desc(?st)
Listing items (QiD and Label) from list of ORCID iD (P496)
[edit]If I give you a list of multiple ORCID iD (P496), e.g. 0000-0003-1829-7482 and 0000-0003-4786-2698 and 0009-0002-2528-5738, can I get a list of QiD and Label. If possible, can the resulting list include all the ORCID iD (P496) with a matching wikidata item, but also include the ORCID iD (P496) that don't have a matching wikidata item? I very much appreciate it. Trilotat (talk) 23:09, 15 November 2025 (UTC)
- Here: https://w.wiki/G7R6 . Note that it's limited how many ORCIDs you can supply this way, the query including protocol overhead may not exceed 1 MiB, so to be safe don't go above 750 kiB. Infrastruktur (talk) 11:11, 16 November 2025 (UTC)
- Great stuff! Thank you! Trilotat (talk) 05:17, 29 November 2025 (UTC)
CS related terms/triples
[edit]Hi, I am looking to create a dataset for RGCN training with CS topics.
The problem I'm having is that the list of qids I have in python contain concepts/topics im interested in, but are pulling very few triples from wikidata (0 - 10). Some of the larger topics are pulling hundreds, but I need a lot more for training data. Any suggestions?
These are the queries in question. The first one works well to pull the labels and qids related to cs, but the second one is not extracting many triples.
- running this gives a list of labels and ids, then i store them into a python dictionary as label: qid
SELECT ?child ?childLabel WHERE {
{
?child wdt:P279?/wdt:P279?/wdt:P279? wd:Q21198. # subclasses of computer science
}
UNION
{
?child wdt:P31?/wdt:P31?/wdt:P31? wd:Q21198. # instances of computer science or its subclasses
}
UNION
{
?child wdt:P361?/wdt:P361?/wdt:P361? wd:Q21198. # part of computer science
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
- then, for each qid i run this query to extract triples, replacing {qid} with the actual qid
SELECT ?concept1 ?concept1Label ?relation ?relationLabel ?concept2 ?concept2Label WHERE {
VALUES ?seed { {qid} }
{
# Part-of hierarchy (P361)
?concept1 (wdt:P361?/wdt:P361?/wdt:P361?) ?seed .
BIND(wdt:P361 AS ?relation)
?concept2 ?relation ?concept1 .
}
UNION
{
# Subclass-of hierarchy (P279)
?concept1 (wdt:P279?/wdt:P279?/wdt:P279?) ?seed .
BIND(wdt:P279 AS ?relation)
?concept2 ?relation ?concept1 .
}
UNION
{
# Instance-of hierarchy (P31)
?concept1 (wdt:P31?/wdt:P31?/wdt:P31?) ?seed .
BIND(wdt:P31 AS ?relation)
?concept2 ?relation ?concept1 .
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en".
}
}
- I add the SPARQL-Template to your queries. So we can easy run your queries. --sk (talk) 15:20, 20 November 2025 (UTC)
Participants to SheSaid
[edit]Hello. I am not sure it is the right place to ask for such help, so please forgive me in advance if I am in the wrong spot and need to ask elsewhere...
I would need a query to answer this question
- on a specific linguistic version of Wikiquote
- I would need the list of usernames who have made a least one edit on that language Wikiquote, using at least once the tag #SheSaid in the comment space, during « starting date » and « ending date ».
- For each username, I would need the display of « the username », date of first edit (within the time frame), date of last edit (within the time frame), number of articles created
- If not too demanding on the server, it would be great to also have, for each editor listed, number of edits to SheSaid entries or number of bytes (all within the time frame). Anything that would help get a sense of the « how involved and active the person is"
- A BONUS would be to display the exact tag the person used. One of my problem is that people use different tags and I had the adapt the initial query to try to capture all that (using AND comment_text RLIKE '.*#[Ss]he[Ss]aid.*’). But getting a sense of which tag they exactly use would help identify the group the person is attached to
I am already using and adaptating three related queries, which may be found here https://en.wikiquote.org/wiki/Wikiquote:SheSaid#Tracking_and_Statistics
- one is essentially listing me New Entries tagged SheSaid between two dates (I adapt those dates depending on the language and the intensity of the request... for example, I rather run the query for two weeks max in English, but it could be four weeks max in other less intensive languages)
- one is essentially listing me « Improved articles » tagged SheSaid between two dates
- one is listing me « new entries » within two dates (which allows me to identify entries which have not been tagged SheSaid)
I can obviously establish the list of participants based on the first and second queries, but this requires for me quite a bit of work, exporting data, importing it in a table, then cleaning up the output to get the unique names (for example, I was able to establish this list a few days ago: https://en.wikiquote.org/wiki/Wikiquote:SheSaid#Participants).
But it took me at least 30 mn to do so, and I have several languages to track. So I think it would way more efficient to have a query directly giving me the list...
Can anyone help me?
Thanks
Anthere (talk) 14:36, 18 November 2025 (UTC)
- @Anthere sadly wikidata can't track contribution of user on project with hashtag. Maybe you can track from this tools. https://hashtags.wmcloud.org/
- I hope this tools can help you.
- -- Empat Tilda (talk) 08:39, 21 November 2025 (UTC)
- Very sad:((( Thank you Empat Tilda. Anthere (talk) 14:57, 21 November 2025 (UTC)
- I wanted to write, that quarry would be write tool for that, but as I can see, You've already got there :) So it is
Resolved here (if those queries are not enough, You should look for help with them), regards, Piastu (talk) 09:48, 29 November 2025 (UTC)
- I wanted to write, that quarry would be write tool for that, but as I can see, You've already got there :) So it is
- Very sad:((( Thank you Empat Tilda. Anthere (talk) 14:57, 21 November 2025 (UTC)
Any item descriptions matching a regular expression.
[edit]How can I use regex to return all items by their item description? -wd-Ryan (Talk/Edits) 17:31, 18 November 2025 (UTC)
- item descriptions matching a regular expression
#title: item descriptions matching a regular expression #defaultView: Table PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX schema: <http://schema.org/> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?item ?itemLabel ?desc WHERE { #?item wdt:P31 ?some. # is something ?item schema:description ?desc. # get description FILTER (lang(?desc) = "en"). # only english description FILTER(REGEX(STR(?desc), "17[0-1][0-5]")) # regexp ?item rdfs:label ?item_label FILTER(LANG(?item_label) = "en") } Limit 25
- This is my query for you. But the query service on Wikidata will get a timeout if you run the query without the clause "Limit ...". But you can test it on other query server. My favorite is Qlever. Here is your query there. It need around 30 seconds to run. But if you can specify your query (like only humans or so) it will be better for the performance. For example Regexp only human run in 5 seconds. --sk (talk) 15:50, 20 November 2025 (UTC)
- Thank you! Very helpful with many options. -wd-Ryan (Talk/Edits) 18:22, 20 November 2025 (UTC)
People buried in Italian (or a subregion) cemeteries
[edit]I would like to improve Wikidata and OpenStreetMap cemeteries mapping. I would like to have a list of all people buried in Italian cemeteries, or a specifici region cemeteries. Having a column with the Q-ID, one with the person name and one with the cemetery would be cool, having an extra column(s) with the city/region would be even cooler. Thanks! Ivanbranco (talk) 10:37, 20 November 2025 (UTC)
- Try it!
SELECT ?item ?itemLabel ?pob ?pobLabel ?region ?regionLabel WHERE { ?item wdt:P31 wd:Q5. # is human ?item wdt:P119 ?pob. # has place of burial (pob) ?pob wdt:P17 wd:Q38. # in Italy OPTIONAL{?pob wdt:P131 ?region} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } #FILTER(STRENDS(str(?item), '5' )). # filter by last number of item #FILTER(STRSTARTS(?itemLabel, 'Alex')) . # filter the name } order by xsd:integer(STRAFTER(str(?item), 'Q')) #limit 1000
- @Ivanbranco: Here is my query for you. Best regards --sk (talk) 16:53, 20 November 2025 (UTC)
Video games with the wrong genre
[edit]Could i get a query of video games whose genre is an instance of (P31) of television series genre (Q12343431), television genre (Q15961987), film genre (Q201658), literary genre (Q223393), anime and manga genre (Q4178140), anime genre (Q103110540) or manga genre (Q103112098)--Trade (talk) 16:50, 21 November 2025 (UTC)
- @Trade: This is my query for you. I hope this help. Best regards --sk (talk) 21:48, 21 November 2025 (UTC)
Taxon image qualifiers
[edit]Hi. I would need to rank which are the most used qualifiers with image (P18) in taxons. So far, I have this:
- Try it!
SELECT ?qualifierProperty ?qualifierPropertyLabel (COUNT(*) AS ?count) WHERE { VALUES ?class { wd:Q16521 wd:Q23038290 wd:Q937228 } ?item wdt:P31 ?class ; p:P18 ?statement . ?statement ?qualifierProperty ?qualifierValue . FILTER STRSTARTS(STR(?qualifierProperty), "http://www.wikidata.org/prop/qualifier/") SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } GROUP BY ?qualifierProperty ?qualifierPropertyLabel ORDER BY DESC(?count)
but I cannot avoid the timeout. Could somebody help me get the results? Thanks in advance, Paucabot (talk) 16:58, 22 November 2025 (UTC)
- @Paucabot: If you use your query on another query-server and remove the label, it work very fast. Here is your query at qlever.dev. --sk (talk) 21:21, 22 November 2025 (UTC)
- Thanks, Stefan Kühn! Paucabot (talk) 05:13, 23 November 2025 (UTC)
Make this query more efficient/timing out
[edit]Hi, this string search often times out. Any idea?
** Nevermind, removing the 279* makes it more doable
SELECT distinct ?item ?itemLabel WHERE { {
SELECT ?item WHERE {?item wdt:P31/wdt:P279* wd:Q55488;wdt:P17 wd:Q37.
minus { ?item wdt:P5817 ?état_d_usage. }
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "lt.wikipedia.org";
wikibase:api "Generator";
mwapi:generator "search";
mwapi:gsrsearch "buvusi";
mwapi:gsrlimit "max".
?item wikibase:apiOutputItem mwapi:item .
}
}
}
hint:Prior hint:runFirst "true".
} LIMIT 30
Bouzinac 💬●✒️●💛 22:29, 26 November 2025 (UTC)
- What is the goal of your query? This part of the query get zero rows. So what do you want? --sk (talk) 08:16, 27 November 2025 (UTC)
- @Bouzinac: With this query you get all 602 rows of train stations in Lithuania. So 602 rows should not give a timeout. --sk (talk) 08:20, 27 November 2025 (UTC)
- To make it more clear, here's another use case : searching for plwiki articles containing a certain word "dawna" (closed). This query sometimes works sometimes times out https://query.wikidata.org/#SELECT%20distinct%20%3Fitem%20%3FitemLabel%20WHERE%20%7B%20%7B%0A%20%20%20SELECT%20%3Fitem%20WHERE%20%7B%3Fitem%20wdt%3AP31%20wd%3AQ55488%3Bwdt%3AP17%20wd%3AQ36.%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20minus%20%7B%20%3Fitem%20wdt%3AP5817%20%3F%C3%A9tat_d_usage.%20%7D%0A%20%20%20%20SERVICE%20wikibase%3Amwapi%20%7B%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aendpoint%20%22pl.wikipedia.org%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3Aapi%20%22Generator%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mwapi%3Agenerator%20%22search%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mwapi%3Agsrsearch%20%22dawna%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mwapi%3Agsrlimit%20%22max%22%20.%0A%20%20%20%20%20%20%3Fitem%20wikibase%3AapiOutputItem%20mwapi%3Aitem%20.%0A%20%20%20%20%7D%0A%20%20%7D%20%0A%20%7D%0A%20hint%3APrior%20hint%3ArunFirst%20%22true%22.%0A%7D%20LIMIT%20498
- @Bouzinac: With this query you get all 602 rows of train stations in Lithuania. So 602 rows should not give a timeout. --sk (talk) 08:20, 27 November 2025 (UTC)
- @Bouzinac: What do you think make this query? It search for the word "dawna" in plwiki and give you the wikidata-items? When I check the first item in the result, it was Q929475. But there is no word "dawna" in the Wikidata-Item and there is no plwiki-article. So I don't get it! Please describe your intention with this query. What do you search with this query? -- sk (talk) 18:05, 27 November 2025 (UTC)
- Ah... so this query returns in fact false positives. Q929475 should not pop out. I refined slightly
- Try it!
SELECT DISTINCT ?item ?itemLabel WHERE { { SELECT ?item WHERE { ?item wdt:P31 wd:Q55488; wdt:P17 wd:Q36. MINUS { ?item wdt:P5817 ?etat_d_usage. } # ❗ Garder seulement les éléments ayant un article sur Wikipédia polonaise ?plArticle schema:about ?item ; schema:isPartOf <https://pl.wikipedia.org/> . # Recherche MWAPI SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "pl.wikipedia.org"; wikibase:api "Generator"; mwapi:generator "search"; mwapi:gsrsearch "dawna"; mwapi:gsrlimit "max". ?item wikibase:apiOutputItem mwapi:item . } } } SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,en". } hint:Prior hint:runFirst "true". } LIMIT 498
returns only with plwikis but still false positives. Bouzinac 💬●✒️●💛 18:43, 27 November 2025 (UTC)
- This query looks to be very fast https://w.wiki/GLRJ but still false positives Bouzinac 💬●✒️●💛 18:56, 27 November 2025 (UTC)
- Please no more queries. Write what you want. Do you search for train stations articles in plwiki-articles with "dawna" and want a list of Wikidata Items? I can not help, if I don't know what you really want! If you want only train-stations with a plwiki-article then use this query.--sk (talk) 19:08, 27 November 2025 (UTC)
- The string search "dawna" does not work as expected. Bouzinac 💬●✒️●💛 19:09, 27 November 2025 (UTC)
- So don't use it. And if You need help – write what do You expect, what do You want to achieve (not how You try to do that – that can help in second or third step – but step first should be purpose of query, like list of defunct train station in X with (or without?) article on plWiki) – it can help to make decision to rely on label (dawna for example), or better not, and check for some other conditions. (And if You're writing not work as expected it would be good to give some example of unexpected behavior, to let others understand, what You didn't expect). Piastu (talk) 09:20, 28 November 2025 (UTC)
- The string search "dawna" does not work as expected. Bouzinac 💬●✒️●💛 19:09, 27 November 2025 (UTC)
- Please no more queries. Write what you want. Do you search for train stations articles in plwiki-articles with "dawna" and want a list of Wikidata Items? I can not help, if I don't know what you really want! If you want only train-stations with a plwiki-article then use this query.--sk (talk) 19:08, 27 November 2025 (UTC)
Merge two items
[edit]Can someone merge Q136298745 to Q137168957? As the former is a bit confusing without the disambiguation or is it fine? If it is, then requesting to delete the latter which was made by me. D.18th (talk) 16:12, 30 November 2025 (UTC)
merged, regards, Piastu (talk) 20:26, 30 November 2025 (UTC)

