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 2026/11. |
On this page all sections tagged with {{Section resolved|1=~~~~}} after 2 days are automatically archived.
|
Deprecated ethnic group
[edit]Could someone make a query for ethnic group (P172): Japanese people (Q161652) with deprecated rank? Also, a separate query for ethnic group (P172): Japanese people (Q161652) and qualifier reason for deprecated rank (P2241): source known to be unreliable (Q22979588), please? (This second group doesn't need to filter to deprecated rank.) TE(æ)A,ea. (talk) 14:18, 27 September 2026 (UTC)
- Empat Tilda (talk) 07:51, 7 October 2026 (UTC)Try it!
#with deprecated rank SELECT ?item ?itemLabel WHERE { ?item p:P172 ?statement . ?statement ps:P172 wd:Q161652 ; wikibase:rank wikibase:DeprecatedRank . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,id" . } }
- Empat Tilda (talk) 08:02, 7 October 2026 (UTC)Try it!
#with qualifier P2241 SELECT ?item ?itemLabel WHERE { ?item p:P172 ?statement . ?statement ps:P172 wd:Q161652 ; pq:P2241 wd:Q22979588 . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,id" . } }
Current electoral districts
[edit]I'd like to query the current electoral districts for a country (Hungary)—that is, I want to exclude any electoral districts that have been abolished from the results. I'm trying this query, but it's not returning any results (“No matching records found”). What did I do wrong? Could someone help me fix it?
Thanks in advance for your help! Pallor (talk) 11:34, 5 October 2026 (UTC)
SELECT ?item ?itemLabel ?end ?start ?ps WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
?item wdt:P17 wd:Q28.
?item p:P31 ?ps.
?ps ps:P31 wd:Q192611;
pq:P571 ?start.
OPTIONAL { ?ps pq:P571 ?start. }
OPTIONAL { ?ps pq:P576 ?end. }
FILTER((!(BOUND(?end)))|| (?end > (NOW())))
}
- @Pallor: I have change your query:
SELECT ?item ?itemLabel ?end ?start ?ps
WHERE {
?item wdt:P17 wd:Q28.
?item p:P31 ?ps.
?ps ps:P31 wd:Q192611. #;
#pq:P571 ?start.
MINUS {?item wdt:P576 [] } # no old
OPTIONAL { ?item wdt:P571 ?start. }
#OPTIONAL { ?ps pq:P571 ?start. }
#OPTIONAL { ?ps pq:P576 ?end. }
#FILTER((!(BOUND(?end)))|| (?end > (NOW())))
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
- Now I see 106 electoral districts of Hungary. Is this correct? Best regards --sk (talk) 10:32, 8 October 2026 (UTC)
- Thank you so much for your help! Yes, there should be 106 results—that's fine. Do you know what was wrong with my query? Pallor (talk) 14:02, 10 October 2026 (UTC)
- Try it!
SELECT ?item ?itemLabel ?end ?start ?ps WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } ?item wdt:P17 wd:Q28. ?item p:P31 ?ps. ?ps ps:P31 wd:Q192611. #; # pq:P571 ?start. OPTIONAL { ?ps pq:P571 ?start. } OPTIONAL { ?ps pq:P576 ?end. } FILTER((!(BOUND(?end)))|| (?end > (NOW()))) }
- @Pallor: If I comment line number 6 out, then I get over 900 results. But with line 6, there are zero results. I think this is the problem. --sk (talk) 10:11, 14 October 2026 (UTC)
- @Stefan Kühn:t’s interesting, because the results list includes several constituencies containing ‘P576’, even though the last line is specifically designed to ensure that only those with a termination date earlier than today’s date are included. Anyway, the query you suggested works perfectly; thank you for looking into it. Pallor (talk) 10:55, 14 October 2026 (UTC)
timeline
[edit]I'd like to have a query visualizing in timeline from 1945 to 2000 of: Q796897 , Q1541071, Q11696, italian Q7278 or Q17127659 or Q48204 with P1142=Q696116, italian Q12414919 with P1142=Q696116, italian Q2223653 and Q750215 , Q1139665, italian Q5 with P1142=Q696116 Thanks. Susanna Susanna Giaccai (talk) 15:01, 8 October 2026 (UTC)
- What do you mean by "visualizing" here? Did you try to look at these items in Reasonator? Infovarius (talk) 15:34, 11 October 2026 (UTC)
- I am not able to use Reasonator. I mean that I'd like tu see the data in timeline format to give an immediate vision of italian history of those years something like this https://js.histropedia.com/examples/period-lines#period-lines . The time lime must have : first line with head of government of the Italian Republic from 1945 to 2000, second line Italian Minister of the Interior from 1945 to 2000 and so nn. The purpose of this activity is to have an immediate idea of neofascist persons, organizations and massacre in Italy from 1945 to 2000. Thanks Susanna Giaccai (talk) 05:50, 12 October 2026 (UTC)
- Reasonator is used like this: https://reasonator.toolforge.org/#/Q1541071. There can be timeline if there are appropriate claims. But it's not adjustable. You can't have many lines at once. Neither in Wikidata Query Service (as I know). May be you have to use Histropedia somehow? Infovarius (talk) 17:11, 13 October 2026 (UTC)
- I am not able to use Reasonator. I mean that I'd like tu see the data in timeline format to give an immediate vision of italian history of those years something like this https://js.histropedia.com/examples/period-lines#period-lines . The time lime must have : first line with head of government of the Italian Republic from 1945 to 2000, second line Italian Minister of the Interior from 1945 to 2000 and so nn. The purpose of this activity is to have an immediate idea of neofascist persons, organizations and massacre in Italy from 1945 to 2000. Thanks Susanna Giaccai (talk) 05:50, 12 October 2026 (UTC)
- Susannas timeline
#title: Susannas timeline #defaultView:Timeline SELECT DISTINCT ?item ?itemLabel ?starttime ?image WHERE { VALUES ?instance_of { wd:Q796897 wd:Q1541071 wd:Q11696 } ?item p:P39 ?statement. ?statement ps:P39 ?instance_of. ?statement pq:P580 ?starttime. OPTIONAL {?item wdt:P18 ?image} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- @Giaccai: Hello Susanna, here is a first query for you. But I don't full understand your request. Maybe you can describe your request a little bit better. --sk (talk) 08:33, 14 October 2026 (UTC)
- Thanks, It is nearly this, but I dont need photos, the timelist must begin from 1945 and end in 2000. Each item must have also end date. For other item you propose to make a different query? Susanna Giaccai (talk) 07:30, 15 October 2026 (UTC)
- Susannas timeline
#title: Susannas timeline #defaultView:Timeline SELECT DISTINCT ?item ?itemLabel ?instance_ofLabel ?starttime #?image WHERE { VALUES ?instance_of { wd:Q796897 } # wd:Q1541071 wd:Q11696 } ?item p:P39 ?statement. ?statement ps:P39 ?instance_of. ?statement pq:P580 ?starttime. ?statement pq:P582 ?endtime. FILTER (YEAR(?starttime) >= 1945) FILTER (YEAR(?starttime) <= 2000) #OPTIONAL {?item wdt:P18 ?image} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- @Giaccai: Hello Susanna, here is my next query for you. Only "Prime Minister of Italy". There are so many. You can change it in line 5, if you want also "President of the United States" and so on. - The query show only when start date is between year 1945 and 2000. --sk (talk) 10:19, 15 October 2026 (UTC)
- In Italy we have many changes of political men ;-(. Il is possible to see end time of each political rule, and also final end time for a minister who succeded to himself many time as [Rognoni] Susanna Giaccai (talk) 12:19, 15 October 2026 (UTC)
- I change only line 2 and 3 and now I see all political men with start and end date. If I switch in line 2 back to "Timeline", then the result is not good to read. --sk (talk) 12:29, 15 October 2026 (UTC)Susannas timeline
#title: Susannas timeline #defaultView:table SELECT DISTINCT ?item ?itemLabel ?instance_ofLabel ?starttime ?endtime #?image WHERE { VALUES ?instance_of { wd:Q796897 wd:Q1541071 wd:Q11696 } ?item p:P39 ?statement. ?statement ps:P39 ?instance_of. ?statement pq:P580 ?starttime. ?statement pq:P582 ?endtime. FILTER (YEAR(?starttime) >= 1945) FILTER (YEAR(?starttime) <= 2000) #OPTIONAL {?item wdt:P18 ?image} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- Can you please make e query for italian Q5 with P1142=Q696116 date 1945-2000. Thanks Susanna Giaccai (talk) 15:35, 15 October 2026 (UTC)
- Susannas timeline number 2
#title: Susannas timeline number 2 #defaultView:Timeline SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?date_of_birth ?date_of_death WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P1142 wd:Q696116. OPTIONAL { ?item wdt:P18 ?image. } # image OPTIONAL { ?item wdt:P569 ?date_of_birth. } OPTIONAL { ?item wdt:P570 ?date_of_death. } FILTER (?date_of_birth >= "1945-01-01T00:00:00Z"^^xsd:dateTime) # born after 1944 FILTER (?date_of_birth <= "2000-12-31T00:00:00Z"^^xsd:dateTime) # born before 2001 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
@Giaccai: Hello Susanna, here your next query. --sk (talk) 18:07, 15 October 2026 (UTC)
- This is better, thanks: I beg you pardon if I continue to ask you improvements. Why i see Melissa Dominguez Rui who is non italian but spaniol? Is it possible to se a line till 2000 for person that are still living? Susanna Giaccai (talk) 07:31, 16 October 2026 (UTC)
- Susannas timeline number 2
#title: Susannas timeline number 2 #defaultView:Timeline SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?date_of_birth ?date_of_death WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P1142 wd:Q696116. ?item wdt:P27 wd:Q38. # only italian OPTIONAL { ?item wdt:P18 ?image. } # image OPTIONAL { ?item wdt:P569 ?date_of_birth. } #OPTIONAL { ?item wdt:P570 ?date_of_death. } ?item wdt:P570 []. # only people without date_of_death FILTER (?date_of_birth >= "1945-01-01T00:00:00Z"^^xsd:dateTime) # born after 1944 FILTER (?date_of_birth <= "2000-12-31T00:00:00Z"^^xsd:dateTime) # born before 2001 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- @Giaccai: Hello Susanna, I add one code line (only italian) and another code line ( only people without date_of_death). Is this what you want? Best regards --sk (talk) 07:58, 16 October 2026 (UTC)
- Now I see only people died, and the line of their life does'nt begin wikth their birth end end with their death.I asked to se le line of leaving pearson to end in 2000. Susanna Giaccai (talk) 11:58, 16 October 2026 (UTC)
- Susannas timeline number 2
#title: Susannas timeline number 2 #defaultView:Timeline SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?date_of_birth ?date_of_death WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P1142 wd:Q696116. ?item wdt:P27 wd:Q38. # only italian OPTIONAL { ?item wdt:P18 ?image. } # image OPTIONAL { ?item wdt:P569 ?date_of_birth. } #OPTIONAL { ?item wdt:P570 ?date_of_death. } MINUS {?item wdt:P570 ?date_of_death}. # only people without date_of_death FILTER (?date_of_birth >= "1945-01-01T00:00:00Z"^^xsd:dateTime) # born after 1944 FILTER (?date_of_birth <= "2000-12-31T00:00:00Z"^^xsd:dateTime) # born before 2001 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } }
- Now I see only people died, and the line of their life does'nt begin wikth their birth end end with their death.I asked to se le line of leaving pearson to end in 2000. Susanna Giaccai (talk) 11:58, 16 October 2026 (UTC)
- @Giaccai: Hello Susanna, ok, I hope I fix this with the new query. --sk (talk) 13:59, 16 October 2026 (UTC)
Times out
[edit]Hello, despite its simplicity, this always times out : any ideas?
SELECT ?masculin WHERE {
?masculin wdt:P21 wd:Q6581097.
minus { ?masculin wdt:P31 ?nature. }
}
LIMIT 10
Bouzinac 💬●✒️●💛 12:55, 18 October 2026 (UTC)
- run it with Qlever but you'll need to add type constraint like P31=Q5 to avoid timeout
- Empat Tilda (talk) 15:55, 18 October 2026 (UTC)Try it!
PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?masculin WHERE { ?masculin wdt:P21 wd:Q6581097. minus { ?masculin wdt:P31 ?nature. } FILTER(STRSTARTS(STR(?masculin), "http://www.wikidata.org/entity/Q")) } LIMIT 1000
- I was in fact searching for items without P31 ressembling to human beings not effectively P31=Q5. Bouzinac 💬●✒️●💛 19:16, 19 October 2026 (UTC)
Davis Cup player
[edit]Hi, I'm looking for a query that will display tennis players (P106 = Q10833314) that have the old Davis Cup player id (P2641) but do not yet have the new Davis Cup player id (P13958). Thanks! Wolbo (talk) 18:43, 29 October 2026 (UTC)
SELECT DISTINCT ?item ?itemLabel ?oldDavisCupId WHERE {
?item wdt:P106 wd:Q10833314;
wdt:P2641 ?oldDavisCupId.
FILTER NOT EXISTS {
?item wdt:P13958 ?newDavisCupId.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
- Wolbo, here you go. Regards, ZI Jony (Talk) 18:31, 31 October 2026 (UTC)
- Seems to work fine. Thanks! --Wolbo (talk) 23:07, 31 October 2026 (UTC)
Nombres
[edit]Por qué, hasta principios del SXX que yo sepa, se usaron en Castilla nombres (para mujeres) como Senén y Abdona. MarciaA Gutiérrez (talk) 08:47, 4 November 2026 (UTC)
