query-bd3169ab6ca25f2f3c8eebea0a6f99de

rq turtle/ttl

Give me the Bundesländer, ordered by the number of their affiliations to NFDI, detailed by afiliationtype!

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?aLabel (COUNT(*) AS ?number)
WHERE { 
  {
    SELECT DISTINCT ?a ?w ?p
    WHERE {  
    {
    ?w wdt:P463 wd:Q105757481 .
  } UNION {
    ?p wdt:P31 wd:Q98270496 .
    ?p p:P1416 ?statement .
    ?statement ps:P1416 ?w .
    OPTIONAL { ?statement pq:P3831 ?affiliationType .}
    FILTER (?affiliationType = wd:Q54875338)
  }
      OPTIONAL {
      ?w wdt:P131+ ?a .
      ?a  wdt:P31 wd:Q1221156 .
      }
    }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de" . }
} GROUP BY ?aLabel
ORDER BY DESC(?number)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?a") v3("?affiliationType") v7("?number") v4("?p") v5("?statement") v2("?w") c14(["de"]):::literal c2(["wd:Q105757481"]):::iri c12(["bd:serviceParam"]):::iri c10(["wd:Q1221156"]):::iri c5(["wd:Q98270496"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["?affiliationType = 'wd:Q54875338'"]] f0 --> v3 v4 --"p:direct/P31"--> c5 v4 --"p:P1416"--> v5 v5 --"p:statement/P1416"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P3831".-> v3 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P463"--> c2 end union0r <== or ==> union0l end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P131".-> v6 v6 --"p:direct/P31"--> c10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end bind2[/"count(*)"/] bind2 --as--o v7