query-1c9cc414ab85b02f6bed2c97fa471977

rq turtle/ttl

yield less results.(Q2934)goat or (Q172923)Capra , because lower levels such as (Q189804)Caprinae I interpreted “goat species” as anything below

Use at

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#>
SELECT ?species ?speciesLabel ?statusLabel
WHERE {
   {
  SELECT ?species ?status WHERE {
    ?species (wdt:P171|wdt:P279)* wd:Q189804; # apparently (some?) goat species are subclasses of rather than subtaxons of goat?
             wdt:P141 ?status.
  }
}
   {
  # assign a numerical rank to each possible status so we can order them properly
  SELECT ?status ?rank WHERE {
    VALUES (?status ?rank) {
      (wd:Q3245245 0)
      (wd:Q56660255 0)
      (wd:Q211005 1)
      (wd:Q158862 2)
      (wd:Q719675 3)
      (wd:Q278113 4)
      (wd:Q11394 5)
      (wd:Q219127 6)
      (wd:Q239509 7)
      (wd:Q237350 8)
    }
  }
}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?rank)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?rank") v2("?species"):::projected v4("?status") c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q189804"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P279"--> c2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P171"--> c2 end union0r <== or ==> union0l end v2 --"wdt:P141"--> v4 bind0[/VALUES ?rank ?status/] bind0-->v4 bind0-->v4 bind00(["wd:Q3245245"]) bind00 --> bind0 bind01(["0^^xsd:integer"]) bind01 --> bind0 bind02(["wd:Q56660255"]) bind02 --> bind0 bind03(["0^^xsd:integer"]) bind03 --> bind0 bind04(["wd:Q211005"]) bind04 --> bind0 bind05(["1^^xsd:integer"]) bind05 --> bind0 bind06(["wd:Q158862"]) bind06 --> bind0 bind07(["2^^xsd:integer"]) bind07 --> bind0 bind08(["wd:Q719675"]) bind08 --> bind0 bind09(["3^^xsd:integer"]) bind09 --> bind0 bind010(["wd:Q278113"]) bind010 --> bind0 bind011(["4^^xsd:integer"]) bind011 --> bind0 bind012(["wd:Q11394"]) bind012 --> bind0 bind013(["5^^xsd:integer"]) bind013 --> bind0 bind014(["wd:Q219127"]) bind014 --> bind0 bind015(["6^^xsd:integer"]) bind015 --> bind0 bind016(["wd:Q239509"]) bind016 --> bind0 bind017(["7^^xsd:integer"]) bind017 --> bind0 bind018(["wd:Q237350"]) bind018 --> bind0 bind019(["8^^xsd:integer"]) bind019 --> bind0 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end