query-df939842c7b52d93f97916618c5a9ab1
Species and their sitelinks
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?species ?speciesLabel ?sitelink
WHERE {
?species wdt:P171* wd:Q7377 # Sub-species of mammal
FILTER NOT EXISTS { [] wdt:P171 ?species } # Leaf nodes only
?sitelink schema:about ?species. # Page 'about' species: could be Wikipedia article or not
?species rdfs:label ?speciesLabel filter (lang(?speciesLabel) = "en")
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?sitelink"):::projected
v2("?species"):::projected
v1("?speciesLabel"):::projected
a1((" "))
c3(["wd:Q7377"]):::iri
f0[["?speciesLabel = 'en'"]]
f0 --> v1
f1[["not "]]
subgraph f1e0["Exists Clause"]
e0a1 --"wdt:P171"--> e0v1
e0v1("?species"):::projected
e0a1((" ")):::projected
end
f1--EXISTS--> f1e0
f1 --> a1
f1 --> c2
f1 --> v2
a1 --"wdt:P171"--> v2
v2 --"wdt:P171"--> c3
v3 --"schema:about"--> v2
v2 --"rdfs:label"--> v1