query-3edead6ba7cfaae1c9ad150472a2ae32

rq turtle/ttl

Propertiesmain subject (P921)taxon rank (P105)maintained by WikiProject (P6104)

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#>
#title: Works about predation and at least two species, at least one of which is in scope
#defaultView:Table

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

SELECT ?count # (CONCAT("/topics/Q202864,", SUBSTR(STR(?topic), 32)) AS ?countUrl)
       ?topic ?topicLabel # (CONCAT("/topic/", SUBSTR(STR(?topic), 32)) AS ?topicUrl)
       ?topic1 ?topic1Label # (CONCAT("/topic1/", SUBSTR(STR(?topic), 32)) AS ?topic1Url)
       ?example_work ?example_workLabel # (CONCAT("/work/", SUBSTR(STR(?example_work), 32)) AS ?example_workUrl)
WHERE {
  # Label the results
   {
  SELECT DISTINCT ?topic ?topic1 (COUNT(?work) AS ?count) (SAMPLE(?work) AS ?example_work) WHERE {
    # Find works for the specific queried topic
      ?work wdt:P921 target: .

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

    # Filter for species
    ?topic wdt:P105 wd:Q7432 .
    ?topic1 wdt:P105 wd:Q7432 .

    # Filter for topics within scope of WikiProject Invasion biology
    ?topic wdt:P6104 wd:Q56241615 .

    # Avoid listing the queried topic
      FILTER (target: != ?topic)
      FILTER (target: != ?topic1)
      FILTER (?topic != ?topic1)
}
  GROUP BY ?topic ?topic1
}  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; v5("?count"):::projected v5("?example_work"):::projected v2("?topic"):::projected v3("?topic1"):::projected v4("?work") c10(["en,da,de,es,fr,jp,nl,no,ru,sv,zh"]):::literal c4(["wd:Q7432"]):::iri c8(["bd:serviceParam"]):::iri c6(["wd:Q56241615"]):::iri c1(["wd:Q170430"]):::iri f0[["?topic != ?topic1"]] f0 --> v2 f0 --> v3 f1[["'wd:Q170430' != ?topic1"]] f1 --> v3 f2[["'wd:Q170430' != ?topic"]] f2 --> v2 v4 --"wdt:P921"--> c1 v4 --"wdt:P921"--> v2 v4 --"wdt:P921"--> v3 v2 --"wdt:P105"--> c4 v3 --"wdt:P105"--> c4 v2 --"wdt:P6104"--> c6 bind5[/"count(?work)"/] v4 --o bind5 bind5 --as--o v5 bind6[/"sample(?work)"/] v4 --o bind6 bind6 --as--o v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end