query-9dc8efe8f834e73aa2805ffacd0231bd
Common parent taxons of 2 species SELECT ?item ?itemLabel ?depth1 ?depth2 ?taxon_rankLabel { SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" . gas:program gas:in wd:Q42196 . gas:program gas:linkType wdt:P171 . gas:program gas:out ?item . gas:program gas:out1 ?depth1 . } SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" . gas:program gas:in wd:Q20980826 . gas:program gas:linkType wdt:P171 . gas:program gas:out ?item . gas:program gas:out1 ?depth2 . } OPTIONAL { ?item wdt:P105 ?taxon_rank . } SERVICE wikibase:label {bd:serviceParam wikibase:language "en" } } ORDER BY (?depth1 + ?depth2) LIMIT 1 # Remove limit to see all higher levels
Use at
- https://query.wikidata.org/sparql
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
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#>
#Common parent taxons of 2 species
SELECT ?item ?itemLabel ?depth1 ?depth2 ?taxon_rankLabel
{
SERVICE gas:service
{
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" .
gas:program gas:in wd:Q42196 .
gas:program gas:linkType wdt:P171 .
gas:program gas:out ?item .
gas:program gas:out1 ?depth1 .
}
SERVICE gas:service
{
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" .
gas:program gas:in wd:Q20980826 .
gas:program gas:linkType wdt:P171 .
gas:program gas:out ?item .
gas:program gas:out1 ?depth2 .
}
OPTIONAL { ?item wdt:P105 ?taxon_rank . }
SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}
ORDER BY (?depth1 + ?depth2)
LIMIT 1 # Remove limit to see all higher levels