query-0c6db74e5261911a1a472550b503d664

rq turtle/ttl

better version of the one above SELECT $item ?instance_author_count $string_author_count ?author_name ?rank WHERE { # FILTER (?count >= 7) FILTER (?string_author_count = 1) FILTER (?instance_author_count = 1) FILTER (STR(?rank) = "2") { SELECT DISTINCT ?item (COUNT (?author) as ?string_author_count) WHERE { ?item wdt:P31 wd:Q13442814 ; wdt:P179 wd:Q57081850 . ?item wdt:P2093 ?author. } GROUP BY (?item) } { SELECT DISTINCT ?item (COUNT (?instance_author) as ?instance_author_count) WHERE { ?item wdt:P31 wd:Q13442814 ; wdt:P179 wd:Q57081850 . OPTIONAL { ?item wdt:P50 ?instance_author. } } GROUP BY (?item) } { SELECT DISTINCT ?item (xsd:string(?author) AS ?author_name) ?rank WHERE { ?item wdt:P31 wd:Q13442814 ; wdt:P179 wd:Q57081850 . ?item p:P2093 [ ps:P2093 ?author ; pq:P1545 ?rank ] . } } }

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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/>
# better version of the one above
SELECT $item ?instance_author_count $string_author_count ?author_name ?rank WHERE {
  # FILTER (?count >= 7)
  FILTER (?string_author_count = 1)
  FILTER (?instance_author_count = 1)
  FILTER (STR(?rank) = "2")
  {
    SELECT DISTINCT ?item (COUNT (?author) as ?string_author_count) WHERE {
      ?item wdt:P31 wd:Q13442814 ; 
            wdt:P179 wd:Q57081850 .
      ?item wdt:P2093 ?author.
    }
    GROUP BY (?item)
  }
  {
    SELECT DISTINCT ?item (COUNT (?instance_author) as ?instance_author_count) WHERE {
      ?item wdt:P31 wd:Q13442814 ; 
            wdt:P179 wd:Q57081850 .
      OPTIONAL { ?item wdt:P50 ?instance_author. }
    }
    GROUP BY (?item)
  }
  {
    SELECT DISTINCT ?item (xsd:string(?author) AS ?author_name) ?rank WHERE {
      ?item wdt:P31 wd:Q13442814 ; 
            wdt:P179 wd:Q57081850 .
      ?item p:P2093 [ 
        ps:P2093 ?author ; 
        pq:P1545 ?rank 
      ] .
    }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?author") v7("?author_name"):::projected v6("?instance_author") v7("?instance_author_count"):::projected v4("?item"):::projected v1("?rank"):::projected v6("?string_author_count"):::projected a1((" ")) c6(["wd:Q57081850"]):::iri c4(["wd:Q13442814"]):::iri f0[["str(?rank) = '2'"]] f0 --> v1 f1[["?instance_author_count = '1^^xsd:integer'"]] f1 --> v7 f2[["?string_author_count = '1^^xsd:integer'"]] f2 --> v6 v4 --"p:direct/P31"--> c4 v4 --"p:direct/P179"--> c6 v4 --"p:direct/P2093"--> v5 bind4[/"count(?author)"/] v5 --o bind4 bind4 --as--o v6 v4 --"p:direct/P31"--> c4 v4 --"p:direct/P179"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P50".-> v6 end bind6[/"count(?instance_author)"/] v6 --o bind6 bind6 --as--o v7 v4 --"p:direct/P31"--> c4 v4 --"p:direct/P179"--> c6 a1 --"p:statement/P2093"--> v5 a1 --"p:qualifier/P1545"--> v1 v4 --"p:P2093"--> a1 bind7[/"http://www.w3.org/2001/XMLSchema#string(?author)"/] v5 --o bind7 bind7 --as--o v7