query-c088c6c85eaad6502a1aee7be5f559b9

rq turtle/ttl

tool: scholia PREFIX target1: http://www.wikidata.org/entity/Q36 PREFIX target2: http://www.wikidata.org/entity/Q52

SELECT ?number_of_works ?number_of_authors

?organization ?organizationLabel (CONCAT("#organization/", SUBSTR(STR(?organization), 32)) AS ?organizationUrl)

?example_work ?example_workLabel (CONCAT("#work/", SUBSTR(STR(?example_work), 32)) AS ?example_workUrl) WITH { SELECT ?work WHERE { ?work wdt:P921 / (wdt:P361| wdt:P1269 | wdt:P31 | wdt:P279)? target2: } } AS %works WITH { SELECT ?organization (COUNT(DISTINCT ?work) AS ?number_of_works) (COUNT(DISTINCT ?author) AS ?number_of_authors) (SAMPLE(?work) AS ?example_work) WHERE { INCLUDE %works ?work wdt:P50 ?author . ?author ( wdt:P108 | wdt:P1416 ) ?organization . ?organization wdt:P17 target1: . } GROUP BY ?organization } AS %results WHERE { INCLUDE %results SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY DESC(?number_of_works)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# tool: scholia
PREFIX target1: <http://www.wikidata.org/entity/Q36>
PREFIX target2: <http://www.wikidata.org/entity/Q52>

SELECT
  ?number_of_works
  ?number_of_authors

  ?organization ?organizationLabel
  (CONCAT("#organization/", SUBSTR(STR(?organization), 32)) AS ?organizationUrl)

  ?example_work ?example_workLabel (CONCAT("#work/", SUBSTR(STR(?example_work), 32)) AS ?example_workUrl)
WHERE {
   {
  SELECT
    ?organization
    (COUNT(DISTINCT ?work) AS ?number_of_works)
    (COUNT(DISTINCT ?author) AS ?number_of_authors)
    (SAMPLE(?work) AS ?example_work)
  WHERE {
     {
  SELECT 
    ?work
  WHERE {
    ?work wdt:P921 / (wdt:P361| wdt:P1269 | wdt:P31 | wdt:P279)? target2:
  }
}    ?work wdt:P50 ?author .
    ?author ( wdt:P108 | wdt:P1416 ) ?organization .
    ?organization wdt:P17 target1: .
  }
  GROUP BY ?organization
}  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?number_of_works)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?author") v6("?example_work"):::projected v8("?example_workUrl") v5("?number_of_authors"):::projected v5("?number_of_works"):::projected v4("?organization"):::projected v7("?organizationUrl") v2("?work") a1((" ")) c2([http://www.wikidata.org/entity/Q52]):::iri c11([http://www.wikidata.org/entity/Q36]):::iri c13(["bd:serviceParam"]):::iri c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"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; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P279"--> c2 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P31"--> c2 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P1269"--> c2 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P361"--> c2 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; end union0r <== or ==> union0l end v2 --"wdt:P50"--> v3 subgraph union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P1416"--> v4 end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P108"--> v4 end union4r <== or ==> union4l end v4 --"wdt:P17"--> c11 bind3[/"count(?work)"/] v2 --o bind3 bind3 --as--o v5 bind4[/"count(?author)"/] v3 --o bind4 bind4 --as--o v5 bind5[/"sample(?work)"/] v2 --o bind5 bind5 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end bind6[/"concat('#organization/',substring(str(?organization),'32^^xsd:integer'))"/] v4 --o bind6 bind6 --as--o v7 bind7[/"concat('#work/',substring(str(?example_work),'32^^xsd:integer'))"/] v6 --o bind7 bind7 --as--o v8