Wikidata:Request a query/Archive/2017/11
This page is an archive. Please do not modify it. Use the current page, even to continue an old discussion. |
Place of burial without image
SELECT ?item ?itemLabel ?coord
WHERE {
?item wdt:P119 ?p .
?p (wdt:P131)* wd:Q38 .
?p wdt:P265 ?coord .
}
Where item hasn't any image of grave (P1442). Visualization: map display default. Thank you! --Epìdosis 18:35, 30 October 2017 (UTC)
- Try it!
#defaultView:Map SELECT ?item ?itemLabel ?p ?pLabel ?coord WHERE { ?item wdt:P119 ?p . MINUS { ?item wdt:P1442 [] } . ?p wdt:P625 ?coord; wdt:P131* wd:Q38 . SERVICE wikibase:label { bd:serviceParam wikibase:language "it,en" } . }
- Matěj Suchánek (talk) 19:40, 30 October 2017 (UTC)
Korean Wikipedia, most common occupation for women
Hi,
I'd like to know the most popular occupation (P106) of human (Q5) whose gender is female (Q6581072) which has sitelink to Korean Wikipedia (Q17985), and the number of that occupation. I already have a basic query for number of female (Q6581072) in Korean Wikipedia (Q17985).
SELECT (count(?item) as ?c) WHERE {
?item wdt:P21 wd:Q6581072.
?item wdt:P31 wd:Q5.
?war schema:about ?item.
?war schema:isPartOf <https://ko.wikipedia.org/> .
}
— regards, Revi 11:47, 1 November 2017 (UTC)
SELECT ?occupation ?occupationLabel (COUNT(?occupation) AS ?count) WHERE {
?item ^schema:about [ schema:isPartOf <https://ko.wikipedia.org/> ]; wdt:P21 wd:Q6581072; wdt:P31 wd:Q5; wdt:P106 ?occupation .
SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE],en' }
} GROUP BY ?occupation ?occupationLabel ORDER BY DESC(?count)
—MisterSynergy (talk) 11:54, 1 November 2017 (UTC)
Thoroughfares of Paris
Hi all,
I would like to have a query that gives me the items that are subclasses of thoroughfare (Q83620) in the 20 municipal arrondissement (Q702842) of Paris (Q90) (streets, boulevards, etc.). This items have not necessarily located in the administrative territorial entity (P131): Paris (Q90) but for example located in the administrative territorial entity (P131): 8th arrondissement of Paris (Q270230). Thank you! Tubezlob (🙋) 10:33, 30 October 2017 (UTC)
- Don't they all have an identifier?
--- Jura 14:35, 4 November 2017 (UTC)
Genera with no child taxa
Hello! Is there a way to find genera (taxon rank (P105) = genus (Q34740)) with no child taxa (subgenus (Q3238261), section (Q3181348), subsection (Q5998839), species (Q7432))? Korg (talk) 13:02, 4 November 2017 (UTC)
- Try it!
SELECT ?item ?itemLabel ?name { ?item wdt:P105 wd:Q34740 . MINUS { ?item ^wdt:P171 [] } . OPTIONAL { ?item wdt:P225 ?name } . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . }
- Matěj Suchánek (talk) 13:43, 4 November 2017 (UTC)
- Thank you! Korg (talk) 15:17, 4 November 2017 (UTC)
Find the titles containing a string
Hello, can I get help with a very simple script that finds Wikimedia Commons categories containing the string "shape" in title?
Also I would like to ask how to change the script in order to:
- make the search case insensitive
- search whole words instead of string
- search articles instead of categories
- search Wikipedia elements instead of Wikimedia commons elements
Thank you! -- Fructibus (talk) 13:42, 5 November 2017 (UTC)
- Possible with a query but maybe consider using this tool. Cdlt, VIGNERON (talk) 09:24, 7 November 2017 (UTC)
descriptions that have a certain (given) word
I need a query which will give me all the Bengali (bn) descriptions that have a certain (given) word. Doesn't matter order, that word can be first, middle & last in description. e.g when i search for একটি, Wikidata gives me many result. I need same thing with query. For this regular expression would be something like (.*)\একটি(.*)
. Query result should gives me item id & Bengali description only. I need this for fixing certain incorrect word, misspelling in descriptions. --Aftabuzzaman (talk) 17:21, 8 November 2017 (UTC)
- @Aftabuzzaman: আমার আলাপ পাতায় বহু আগে এই রকম কুয়েরি দিয়েছেন, যেটা পরিবর্তন করে দিচ্ছি:
- Try it!
SELECT ?item ?description { ?item ^schema:about/schema:isPartOf/^wdt:P856 wd:Q427715 . # (১) ?item schema:description ?description . FILTER( LANG( ?description ) = 'bn' && REGEX( STR( ?description ), 'একটি' ) ) . } LIMIT 100 # (২)
- যদি (১)-টা বাদ দিয়ে দেন তাহলে কাজ করবে না। সেই লাইনটা বদলাতে পারেন যদি এক ধরনের আইটেম অনুসন্ধান করছেন। অথবা (২)-টা বাড়াতে পারেন। Mahir256 (talk) 05:49, 9 November 2017 (UTC)
- @Mahir256: ধন্যবাদ । --Aftabuzzaman (talk) 16:13, 9 November 2017 (UTC)
Colorize stations by connecting line
Hello! I'm trying to colorize dots in this map according to connecting line:
SELECT ?item ?coords ?itemLabel ?layer WHERE {
?item (wdt:P31/wdt:P279*) wd:Q928830.
?item wdt:P625 ?coords.
?item wdt:P361 wd:Q325309.
?item wdt:P81 ?connecting_line.
BIND (?connecting_line AS ?layer).
SERVICE wikibase:label { bd:serviceParam wikibase:language "eu". }
}
ORDER BY ?itemLabel
The query is ok, but it has some interesting things as only shows one or other connecting line. Is there a possibility to mix something for stations with more than one serving line? -Theklan (talk) 22:34, 9 November 2017 (UTC)
Property as qualifier
I have this query:
select * where {
#values ?prop { wd:P4507 }
?prop p:P1855 [ ps:P1855 ?exampleQ; pq:P4507 ?example ].
}
Basically I want to put ?prop as pq:P4507. Problem in human readable format. I want to have table, where I get all Wikidata property example (P1855) for all props (with the values of them). --Edgars2007 (talk) 15:13, 11 November 2017 (UTC)
- Not sure whether I understand correctly. Do you mean: —MisterSynergy (talk) 15:21, 11 November 2017 (UTC)Try it!
SELECT ?property ?exampleItem ?exampleValue WHERE { ?property wikibase:qualifier ?qualifier; p:P1855 [ ps:P1855 ?exampleItem; ?qualifier ?exampleValue ] }
- Yeah, thanks! --Edgars2007 (talk) 15:41, 11 November 2017 (UTC)
population chart
I wanted to create a query that gives my the population of a certain object by year with male, female and whole population. I got that far, that i get a table with all the values that i need. as soon as i use ?year the chart starts with year zero and no explanation can be found. also i dont get it to show me all values in the chart. there is a zoo of examples and docs but its very difficult to find something helpful.
#defaultView:LineChart
SELECT ?point_in_time ?population ?malePopulation ?femalePopulation WHERE {
{
wd:Q661700 p:P1082 _:wp.
_:wp ps:P1082 ?population.
_:wp pq:P585 ?point_in_time.
BIND(YEAR(?point_in_time) AS ?Jahr)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
}
UNION
{
wd:Q661700 p:P1540 _:mp.
_:mp ps:P1540 ?malePopulation.
_:mp pq:P585 ?point_in_time.
}
UNION
{
wd:Q661700 p:P1539 _:fp.
_:fp ps:P1539 ?femalePopulation.
_:fp pq:P585 ?point_in_time.
}
}
ORDER BY ?point_in_time
Ogmios (Tratsch) 17:48, 11 November 2017 (UTC)
Items with an ISSN and a Wikispecies entry
Can someone write a query for the above, please? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 12:44, 12 November 2017 (UTC)
SELECT ?item ?label ?issn ?specieslink WHERE {
?item p:P236 [ ps:P236 ?issn ] .
?specieslink schema:about ?item; schema:isPartOf <https://species.wikimedia.org/> .
?item rdfs:label ?label .
FILTER(LANG(?label) = 'en' && SUBSTR(STR(?label), 1, 4) = 'ISSN') .
}
—MisterSynergy (talk) 13:03, 12 November 2017 (UTC)
- @MisterSynergy: Thank you. Please could we have a variant of that, for just items where the Wikidata label in English starts "ISSN"? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 21:49, 13 November 2017 (UTC)
- Yes we can. (Query above updated) —MisterSynergy (talk) 22:05, 13 November 2017 (UTC)
- @MisterSynergy: Thank you again, Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 22:09, 13 November 2017 (UTC)
List of identifiers for items with a given type of identifier
Take all items with a CBDB ID (P497). I want a query that gives me all the other authority identifiers of those items. The result would have three columns: first the item, then the name of a type of identifier (e.g. VIAF ID (P214)) then the value of that identifier. The property would have to be instance of (P31) Wikidata property for authority control for people (Q19595382). I tried to adapt this example, but couldn't get it to work: I suppose I'm not clear on the different ways to address a property. Thanks in advance, MartinPoulter (talk) 20:25, 14 November 2017 (UTC)
SELECT ?item ?identifier ?value WITH {
SELECT DISTINCT ?item WHERE {
?item p:P497 []
}
} AS %subquery WHERE {
INCLUDE %subquery .
?identifier wikibase:propertyType wikibase:ExternalId; wikibase:claim ?p; wikibase:statementProperty ?ps; wdt:P31/wdt:P279* wd:Q19595382 .
?item ?p [ ?ps ?value ] .
}
If you remove ; wdt:P31/wdt:P279* wd:Q19595382
, the result includes all identifiers, even those which are not instances of (subclasses of) Wikidata property for authority control for people (Q19595382). —MisterSynergy (talk) 20:39, 14 November 2017 (UTC)
- (editconflict) You were on the right track. It's just that this type of query tends to time-out. Here is one that work(s/ed): [1].
--- Jura 20:41, 14 November 2017 (UTC)
- Thank you both very much. The
?item ?p [ ?ps ?value ]
idiom is new to me, as iswikibase:claim
. Can you point me to an explanation of them? I have access to the Learning SPARQL book. MartinPoulter (talk) 22:14, 15 November 2017 (UTC)
- Thank you both very much. The
- @MartinPoulter: basically mw:Wikibase/Indexing/RDF Dump Format. This page is linked from the Query Service (as “list of prefixes” in the help menu).
- You probably know the
wdt:
prefix which is used for simple access to values of statements, see the first image in the linked page. However, depending on ranks and so on, some values are ignored usingwdt:
. I thus linked to the statement itself (usingp:
prefixes, bound to variable?p
) and then from the statement to the value using theps:
prefix (also bound to a variable,?ps
). - For a single property this would look like
?item p:P31 [ ps:P31 ?value ]
or even more directly?item p:P31/ps:P31 ?value
. The first variant allows you to query further data of the statement within the square brackets, such as qualifiers, references, ranks, and so on. Here it was used because predicate variables don’t work with the slash notation of property paths. wikibase:claim
links the property to the claim predicate, e.g.wd:P31 wikibase:claim p:P31
. There is a table of importantwikibase:
predicates on the linked page as well. In the example it was used to collect all properties with external-identifier data type, bind claim (?p
) and claim simple value (?ps
) predicates, and then query data with the predicate variables. —MisterSynergy (talk) 06:03, 16 November 2017 (UTC)
For an author in Wikidata, get the books (title, isbn, and external ids) from other reference databases using the identifiers listed for him/her in Wikidata
For example, for Douglas Adams (Q42), get all the books he published based on the authority IDs listed for him by querying the other databases. Then allow us to replace his Q with any other entity
(Some IDs from WIKIDATA for Douglas Adams)
Library of Congress authority ID n80076765
VIAF ID 113230702
IMDb ID nm0010930
ISNI 0000 0000 8045 6315
SUDOC authorities 026677636
BnF ID 11888092r
GND ID 119033364
TrWd2 (talk) 17:15, 13 November 2017 (UTC)
- Getting some data from other databases (VIAF, ISNI, IMDb etc.) is not possible in SPARQL. OK, theoretically it would possible, if that other database has sparql endpoint and some other things(?), but... The most realistic variant for you is getting all IDs you want from Wikidata and then write some script, that processes results. --Edgars2007 (talk) 13:46, 16 November 2017 (UTC)
External-id properties, with no formatter URL
A list, please, of "external-id" type properties, with no formatter URL (P1630). Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 14:08, 16 November 2017 (UTC)
SELECT ?property ?propertyLabel WHERE {
?property wikibase:propertyType wikibase:ExternalId .
MINUS { ?property wdt:P1630 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}
—MisterSynergy (talk) 14:23, 16 November 2017 (UTC)
List of Countries - missing Kosovo?
This is a query looking for all items which are an instance of country. But Kosovo (Q1246) does not appear in the list despite having this property and I'm not sure why? Is it because of the rankings? Can I adjust the query to include Kosovo?
- Try it!
SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q6256. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
--D Wells (talk) 02:12, 12 November 2017 (UTC)
- I fixed the rank.
--- Jura 04:53, 12 November 2017 (UTC)- @D Wells, Jura1: Do you think it's OK now? Kosovo (Q1246) is now on the list, but for example South Ossetia (Q23427) and Republic of Abkhazia (Q31354462) not. @D Wells: what is "country"? --Infovarius (talk) 08:24, 20 November 2017 (UTC)
- @Infovarius, Jura1: Thanks yes it's OK now! I ended up using the presence of the emoji flag as an arbitrator of which contries to include for my purposes. D Wells (talk) 14:39, 20 November 2017 (UTC)
- @D Wells, Jura1: Do you think it's OK now? Kosovo (Q1246) is now on the list, but for example South Ossetia (Q23427) and Republic of Abkhazia (Q31354462) not. @D Wells: what is "country"? --Infovarius (talk) 08:24, 20 November 2017 (UTC)
- State is homonym (Q160843): 1) "state with unlimited/total recognition"; 2) state with limited recognition. --Fractaler (talk) 08:55, 20 November 2017 (UTC)
Czech Cultural monuments not in PK catalogue
Hello, I need to search for item that use Czech cultural heritage ID (P762) and where at least one value of the P762 property is not accompanied by a specific qualifier: reason for deprecated rank (P2241): no object page in Památkový katalog for the given ÚSKP identifier (Q42097313). Please note that there are items where one of the values is qualified this way and the other is not: such items should not be displayed in results. We will provide such a list to the Czech heritage institute and ask if their heritage status is still valid (and in that case what is the proper identifier). Thank you, --Vojtěch Dostál (talk) 13:41, 19 November 2017 (UTC)
Query to show all yearly awards with no award for 2016
When an award has no end date, it is often that there is no information added either on Wikidata or on one of the many Wikipedias for recent awards. As 2016 has finished, it is a prime candidate for the target of a query. A follow up query would be needed to find the Wikipedia articles for the award and seek the information for inclusion. The follow up query would be awards with recipients for 2016 with no information on a Wikipedia. Thanks, GerardM (talk) 08:07, 19 November 2017 (UTC)
- Second one is easier:
The following query uses these:
- Items: award (Q618779)
- Properties: instance of (P31) , subclass of (P279) , award received (P166) , point in time (P585)
SELECT ?person ?awardLabel ?personLabel WHERE { ?award wdt:P31/wdt:P279+ wd:Q618779. # award or subtype ?person p:P166 ?statement. # winner of award ?statement ps:P166 ?award; pq:P585 ?time # point in time when awarded FILTER (YEAR(?time)=2016) MINUS {?wp schema:about ?person; FILTER CONTAINS(STR(?wp),"wikipedia") } # no Wikipedia article SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
There doesn't seem to be the data to identify annual awards. Look at Nobel Prize in Literature (Q37922) : no property to suggest that it's annual. MartinPoulter (talk) 16:47, 23 November 2017 (UTC)
Since it doesn't seem to be possible to (reliably) query for annual awards, this query might be the most helpful. Awards that have not been abolished, which have an English Wikipedia article, that have no awardees more recent than 2015,with official URLs where available:
The following query uses these:
- Items: award (Q618779)
- Properties: instance of (P31) , subclass of (P279) , dissolved, abolished or demolished date (P576) , official website (P856) , award received (P166) , point in time (P585)
SELECT ?award ?enwp ?url (MAX(?time) as ?latest) WHERE { ?award wdt:P31/wdt:P279+ wd:Q618779. MINUS { ?award wdt:P576 [] } # Exclude abolished [] p:P166 ?statement. ?statement ps:P166 ?award. ?statement pq:P585 ?time. OPTIONAL{ ?award wdt:P856 ?url } FILTER (YEAR(?time)<2016) FILTER (YEAR(?time)>1960) ?enwp schema:about ?award; schema:isPartOf <https://en.wikipedia.org/> } GROUP BY ?award ?enwp ?url ORDER BY DESC(?latest)
Cheers, MartinPoulter (talk) 16:54, 23 November 2017 (UTC)
Iraqi people with no Arabic label
Hi,
Please could we have people with country of citizenship (P27) = Iraq (Q796), and no label in Arabic? (Then I can modify it for other country/ language pairs). Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 22:08, 21 November 2017 (UTC)
SELECT ?item WHERE {
?item wdt:P27 wd:Q796 .
OPTIONAL {
?item rdfs:label ?label .
FILTER(LANG(?label) = 'ar') .
}
FILTER(!BOUND($label)) .
}
—MisterSynergy (talk) 22:21, 21 November 2017 (UTC)
Adding reference details to query containing compound + smiles strings
Hi,
I have a query that returns all compounds and their smiles strings
SELECT DISTINCT ?compound ?compoundLabel ?canonical_smiles WHERE { ?compound wdt:P233 ?canonical_smiles . SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
I would like to augment it with additional information about the references for the smile string.
For example, for this compound https://www.wikidata.org/wiki/Q26306642 I would like to know that
a) this english page exists: https://www.wikidata.org/wiki/Q26306642 b) the smile string was source from these two articles https://www.wikidata.org/wiki/Q26309894 https://www.wikidata.org/wiki/Q26331003 c) the published date of these two articles
Any tips/pointers would be greatly appreciated,
Thanks – The preceding unsigned comment was added by Iainmwallace (talk • contribs) at 16:09, 23 November 2017 (UTC).
- Here’s a list of SMILES IDs with sources: Note that this contains several result rows for items with several sources. This query groups them together:Try it!
SELECT DISTINCT ?compound ?compoundLabel ?canonical_smiles ?sourceLabel ?publicationDate WHERE { ?compound p:P233 ?statement. ?statement ps:P233 ?canonical_smiles. OPTIONAL { ?statement prov:wasDerivedFrom/pr:P248 ?source. OPTIONAL { ?source wdt:P577 ?publicationDate. } } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY ?compound
--TweetsFactsAndQueries (talk) 09:19, 25 November 2017 (UTC)Try it!SELECT ?compound ?compoundLabel ?canonical_smiles (GROUP_CONCAT(CONCAT(?sourceLabel, IF(BOUND(?publicationDate), CONCAT(", ", STR(?publicationDate)), "")); separator = ";\n") AS ?sources) WHERE { ?compound p:P233 ?statement. ?statement ps:P233 ?canonical_smiles. OPTIONAL { ?statement prov:wasDerivedFrom/pr:P248 ?source. OPTIONAL { ?source wdt:P577 ?publicationDate. } } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?compound rdfs:label ?compoundLabel. ?source rdfs:label ?sourceLabel. } } GROUP BY ?compound ?compoundLabel ?canonical_smiles
How much more does WIki knows compared to my local wikipedia
I have connected P3217 and would like to get an understanding how much more information is available outside the Swedish wiki in wikipedia and wikidata..
Query I would like to see
- Number of articles in different languages for P3217
- Number of articles in different languages for P3217 were we miss a Swedish sv Wikipedia article
- Salgo60 (talk) 06:12, 27 November 2017 (UTC)
SELECT ?item ?itemLabel ?P3217value ?sitelinks WHERE {
?item p:P3217 [ ps:P3217 ?P3217value ]; wikibase:sitelinks ?sitelinks .
MINUS { [] schema:about ?item; schema:isPartOf <https://sv.wikipedia.org/> }
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY DESC(?sitelinks)
This is for your second request. You can modify it to your first request by commenting the line starting with “MINUS” (put a #
as the very first character of this line). —MisterSynergy (talk) 06:33, 27 November 2017 (UTC)
- I added queries to Property talk:P3217 as well.
--- Jura 06:34, 27 November 2017 (UTC)
Bigger than...
Hello. I need a query to find all the articles that have ranking (P1352) with value bigger than 209 and qualifier determination method or standard (P459) with FIFA World Rankings (Q180825). Xaris333 (talk) 14:51, 28 November 2017 (UTC)
SELECT ?item ?value WHERE {
?item p:P1352 [ ps:P1352 ?value; pq:P459 wd:Q180825 ] .
FILTER(?value > 209) .
}
—MisterSynergy (talk) 14:59, 28 November 2017 (UTC)
Federated queries
We need more examples, please, of federated queries. I'm particularly interested in those that use the OSM-related services. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 17:52, 28 November 2017 (UTC)
A functioning query about properties for Wikidata list
I need to make a query for all properties relative to INDUCKS (that is, P4479 to P4485) that can work with {{Wikidata list}}
. My current attempt in User:Sannita/Sandbox is not working, so I don't know if the template can work with properties or not. Thanks in advance. --Sannita - not just another it.wiki sysop 20:02, 26 November 2017 (UTC)
- I guess Listeria currently returns only entities, not properties. --Daniel Mietchen (talk) 23:06, 30 November 2017 (UTC)
I would like to import this list in Wikidata and expand it with data from Wikidata. I would like to request a query which can return speakers of Esperanto that are married to each other, with data about the year of marriage, marriage location and the nationalities of both persons. Robin van der Vliet (talk) (contribs) 21:47, 29 November 2017 (UTC)
- This'd be pretty neat. ~★ nmaia d 23:47, 29 November 2017 (UTC)
- Try it!
SELECT ?item1 ?item1Label ?nation1Label ?item2 ?item2Label ?nation2Label ?year ?placeLabel { ?item1 wdt:P1412 wd:Q143; p:P26 ?statement . ?statement ps:P26 ?item2 . ?item2 wdt:P1412 wd:Q143 . FILTER( STR( ?item1 ) < STR( ?item2 ) ) . OPTIONAL { ?statement pq:P580 ?date . BIND( YEAR( ?date ) AS ?year ) . } . OPTIONAL { ?statement pq:P2842 ?place } . OPTIONAL { ?item1 wdt:P27 ?nation1 } . OPTIONAL { ?item2 wdt:P27 ?nation2 } . SERVICE wikibase:label { bd:serviceParam wikibase:language "eo,en" } . }
- Matěj Suchánek (talk) 16:21, 30 November 2017 (UTC)