query-fb85e46c08e0c4cfde6ddb5b356c500f

rq turtle/ttl

Propertiesmain subject (P921)instance of (P31)subclass of (P279)part of (P361)facet of (P1269)taxon name (P225)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Table

PREFIX target: <http://www.wikidata.org/entity/Q1197552> 

SELECT ?count 
       ?topic ?topicLabel 
       ?example_work ?example_workLabel 
WHERE {
  # Label the results
   {
  SELECT (COUNT(?work) AS ?count) ?topic (SAMPLE(?work) AS ?example_work) WHERE {
    # Find works for the specific queried topic
      ?work wdt:P921/( wdt:P31*/wdt:P279* | wdt:P361+ | wdt:P1269+) target: .

    # Find co-occuring topics
    ?work wdt:P921 ?topic .

    # Filter for taxa
    ?topic wdt:P225 [] .

    # Avoid listing the queried topic
      FILTER (target: != ?topic)
  }
  GROUP BY ?topic
}  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } 
}
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?count"):::projected v4("?example_work"):::projected v2("?topic"):::projected v3("?work") a3((" ")) a1((" ")) a2((" ")) c11(["en,da,de,es,fr,jp,nl,no,ru,sv,zh"]):::literal c9(["bd:serviceParam"]):::iri c1([http://www.wikidata.org/entity/Q1197552]):::iri f0[["http://www.wikidata.org/entity/Q1197552 != ?topic"]] f0 --> v2 v3 --"wdt:P921"--> a1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P1269"--> c1 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P361"--> c1 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c1 end union0r <== or ==> union0l end v3 --"wdt:P921"--> v2 v2 --"wdt:P225"--> a3 bind3[/"count(?work)"/] v3 --o bind3 bind3 --as--o v4 bind4[/"sample(?work)"/] v3 --o bind4 bind4 --as--o v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end