query-ad16effff186950819a864fa5c4ba0c0

rq turtle/ttl

.on Mastodon and on TwitterOriginally posted

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?animal ?animalLabel ?count
WHERE {
   {
  SELECT ?animal (SUM(COALESCE(?quantity, 1)) AS ?count) WHERE {
     {
  SELECT DISTINCT ?animal ?statement WHERE {
    ?work wdt:P31/wdt:P279* wd:Q838948;
          p:P180 ?statement.
    ?statement ps:P180 ?depicted.
    MINUS { ?statement wikibase:rank wikibase:DeprecatedRank. }
    ?depicted wdt:P31? ?animal.
    ?animal wdt:P279+ wd:Q729.
    MINUS { ?animal wdt:P279* wd:Q15978631. }
  }
}
    OPTIONAL { ?statement pq:P1114 ?quantity. }
  }
  GROUP BY ?animal
  HAVING(?count >= 10)
}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?animal"):::projected v7("?count"):::projected v4("?depicted") v6("?quantity") v3("?statement") v2("?work") a1((" ")) c4(["wd:Q838948"]):::iri c8(["wikibase:DeprecatedRank"]):::iri c9(["wd:Q729"]):::iri c10(["wd:Q15978631"]):::iri c14(["bd:serviceParam"]):::iri c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?count >= '10^^xsd:integer'"]] f0 --> v7 v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 v2 --"p:P180"--> v3 v3 --"p:statement/P180"--> v4 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v3 --"wikibase:rank"--> c8 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P31"--> v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; end union0r <== or ==> union0l end v5 --"p:direct/P279"--> c9 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v5 --"p:direct/P279"--> c10 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P1114".-> v6 end bind4[/"sum(?quantity'1^^xsd:integer')"/] v6 --o bind4 bind4 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end