query-67cf5473c691055842c68fa62de2dd80
title: Genera of species with no habitat statements SELECT DISTINCT ?topicparent ?taxonname (COUNT(DISTINCT ?item) AS ?count)
WHERE { hint:Query hint:optimizer "None".
{ SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Search"; wikibase:endpoint "www.wikidata.org"; mwapi:srsearch "habitat and haswbstatement:P31=Q13442814 -haswbstatement:P921=Q52105". ?page_title wikibase:apiOutput mwapi:title. } } UNION { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Search"; wikibase:endpoint "www.wikidata.org"; mwapi:srsearch "habitat -and haswbstatement:P31=Q13442814 -haswbstatement:P921=Q52105". ?page_title wikibase:apiOutput mwapi:title. } } BIND(IRI(CONCAT(STR(wd:), ?page_title)) AS ?item)
?item wdt:P1476 ?title. FILTER REGEX(LCASE(?title), "habitat").
?item wdt:P921 ?topic. ?topic wdt:P171 ?topicparent . ?topicparent wdt:P105 wd:Q34740 . ?topicparent wdt:P225 ?taxonname . FILTER NOT EXISTS { ?topic wdt:P2974 [] } .
} GROUP BY ?topicparent ?taxonname ORDER BY DESC(?count)
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title: Genera of species with no habitat statements
SELECT
DISTINCT
?topicparent ?taxonname (COUNT(DISTINCT ?item) AS ?count)
WHERE {
{ SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Search";
wikibase:endpoint "www.wikidata.org";
mwapi:srsearch "habitat and haswbstatement:P31=Q13442814 -haswbstatement:P921=Q52105".
?page_title wikibase:apiOutput mwapi:title.
}
}
UNION
{ SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Search";
wikibase:endpoint "www.wikidata.org";
mwapi:srsearch "habitat -and haswbstatement:P31=Q13442814 -haswbstatement:P921=Q52105".
?page_title wikibase:apiOutput mwapi:title.
}
}
BIND(IRI(CONCAT(STR(wd:), ?page_title)) AS ?item)
?item wdt:P1476 ?title.
FILTER REGEX(LCASE(?title), "habitat").
?item wdt:P921 ?topic.
?topic wdt:P171 ?topicparent .
?topicparent wdt:P105 wd:Q34740 .
?topicparent wdt:P225 ?taxonname .
FILTER NOT EXISTS { ?topic wdt:P2974 [] } .
}
GROUP BY ?topicparent ?taxonname
ORDER BY DESC(?count)