User:Ambrosia10/Query
For a Wikidata SPARQL queries tutorial, see Wikidata:A beginner-friendly course for SPARQL. To request a new query : Wikidata:Request a query |
New Zealand edit
New Zealand women edit
The following query uses these:
- Items: human (Q5) , female (Q6581072) , New Zealand (Q664)
- Properties: instance of (P31) , sex or gender (P21) , place of birth (P19) , located in the administrative territorial entity (P131) , date of birth (P569) , date of death (P570) , place of death (P20)
SELECT ?item ?statements (COUNT(distinct ?sitelink) as ?sites) ?itemLabel ?birth ?pobLabel ?death ?podLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } # for generating label BIND(xsd:integer(STRAFTER(str(?item), "Q")) AS ?qid) . ?item wikibase:statements ?statements . # for counting statements OPTIONAL { ?sitelink schema:about ?item . ?sitelink schema:inLanguage ?lang } # for counting sitelinks ?item wdt:P31 wd:Q5 . # item = humans only ?item wdt:P21 wd:Q6581072 . # gender = female only { ?item wdt:P19 wd:Q664 } # place of birth = New Zealand (Q664) UNION { ?item wdt:P19 ?pob . ?pob wdt:P131* wd:Q664 } # OR place of birth within New Zealand. OPTIONAL { ?item wdt:P569 ?birth } OPTIONAL { ?item wdt:P19 ?pob } OPTIONAL { ?item wdt:P570 ?death } OPTIONAL { ?item wdt:P20 ?pod } } GROUP BY ?item ?statements ?itemLabel ?birth ?pobLabel ?death ?podLabel ORDER BY DESC(?sites)
Paintings by Charles Heaphy edit
The following query uses these:
- Properties: instance of (P31) , creator (P170)
#Paintings by Charles Heaphy SELECT * WHERE { ?item wdt:P31 wd:Q3305213. ?item wdt:P170 wd:Q1064767. }
Invasive species of New Zealand & whether they have an English wikipedia article edit
The following query uses these:
- Items: New Zealand (Q664)
- Properties: invasive to (P5588)
SELECT ?taxon ?taxonLabel ?en WHERE { BIND(IF(BOUND(?english), "+", "-") AS ?en) { SELECT ?taxon ?taxonLabel ?english WHERE { ?taxon wdt:P5588 wd:Q664. OPTIONAL { ?english schema:about ?taxon. FILTER(REGEX(STR(?english), "https://en.wikipedia")) } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } } }
images of endemic species Lepidoptera of New Zealand edit
The following query uses these:
- Properties: instance of (P31) , parent taxon (P171) , taxon rank (P105) , part of (P361) , endemic to (P183) , country (P17) , image (P18)
SELECT ?species ?speciesLabel ?image WHERE { ?species wdt:P31 wd:Q16521; wdt:P171* wd:Q28319; wdt:P105/wdt:P361* wd:Q7432; wdt:P183/wdt:P17 wd:Q664; wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
New Zealand libraries edit
The following query uses these:
- Items: library (Q7075) , New Zealand (Q664)
- Properties: instance of (P31) , subclass of (P279) , country (P17) , coordinate location (P625)
SELECT ?library ?libraryLabel ?coords WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?library (wdt:P31/wdt:P279*) wd:Q7075. ?library wdt:P17 wd:Q664. ?library wdt:P625 ?coords. }