query-b7cab29b8a212ae5468989ba7fe4a91c

rq turtle/ttl

Find prolific authors i.e. authors who are listed as the author of many books SELECT DISTINCT ?authorLabel ?birthDate ?deathDate ?nationalityLabel ?bookCount WHERE { SELECT ?author ?authorLabel ?birthDate ?deathDate ?nationalityLabel (COUNT(?book) AS ?bookCount) WHERE { # expand Q571 to include sub-classes of books for more results # but this will mostly increase query time ?book wdt:P31 wd:Q571; wdt:P50 ?author. OPTIONAL { ?author wdt:P569 ?birthDate. } OPTIONAL { ?author wdt:P570 ?deathDate. } OPTIONAL { ?author wdt:P27 ?nationality. } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?book rdfs:label ?bookLabel. ?author rdfs:label ?authorLabel. ?nationality rdfs:label ?nationalityLabel. } } GROUP BY ?author ?authorLabel ?birthDate ?deathDate ?nationalityLabel } ORDER BY DESC (?bookCount)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Find prolific authors i.e. authors who are listed as the author of many books
SELECT DISTINCT ?authorLabel ?birthDate ?deathDate ?nationalityLabel ?bookCount WHERE {
  SELECT ?author ?authorLabel ?birthDate ?deathDate ?nationalityLabel (COUNT(?book) AS ?bookCount) WHERE {
    # expand Q571 to include sub-classes of books for more results
    # but this will mostly increase query time
    ?book wdt:P31 wd:Q571;
      wdt:P50 ?author.
    OPTIONAL { ?author wdt:P569 ?birthDate. }
    OPTIONAL { ?author wdt:P570 ?deathDate. }
    OPTIONAL { ?author wdt:P27 ?nationality. }
    SERVICE wikibase:label {
      bd:serviceParam wikibase:language "en".
      ?book rdfs:label ?bookLabel.
      ?author rdfs:label ?authorLabel.
      ?nationality rdfs:label ?nationalityLabel.
    }
  }
  GROUP BY ?author ?authorLabel ?birthDate ?deathDate ?nationalityLabel
}
ORDER BY DESC (?bookCount)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?author") v8("?authorLabel"):::projected v4("?birthDate"):::projected v2("?book") v10("?bookCount"):::projected v7("?bookLabel") v5("?deathDate"):::projected v6("?nationality") v9("?nationalityLabel"):::projected c8(["bd:serviceParam"]):::iri c10(["en"]):::literal c2(["wd:Q571"]):::iri v2 --"wdt:P31"--> c2 v2 --"wdt:P50"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P569".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P570".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P27".-> v6 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 v2 --"rdfs:label"--> v7 v3 --"rdfs:label"--> v8 v6 --"rdfs:label"--> v9 end bind1[/"count(?book)"/] v2 --o bind1 bind1 --as--o v10