query-304404cf98d27e50a9942c01fd6da9db

rq turtle/ttl

...also with classes, including parent classes!

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 DISTINCT ?class ?classLabel ?wGeprisID  ?wRORID ?w ?wLabel ?affiliationType ?affiliationTypeLabel ?p ?pLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en" . }
  {
    SELECT DISTINCT ?class ?wGeprisID  ?wRORID ?w ?affiliationType ?p WHERE {  
      {
        ?w wdt:P463 wd:Q105757481 .
        ?w wdt:P31/wdt:P279* ?class .
      } UNION {
        ?p wdt:P31 wd:Q98270496 .
        ?p p:P1416 ?statement .
        ?statement ps:P1416 ?w .
        ?w wdt:P31/wdt:P279* ?class .
        OPTIONAL { ?statement pq:P3831 ?affiliationType .}  
      }
    }
  }
  BIND(IF(! Bound(?affiliationType), "Vereinsmitglied", ?affiliationTypeLabel) AS ?affiliationTypeLabel)
} ORDER BY ASC(?classLabel) ASC(?wLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?affiliationType"):::projected v8("?affiliationTypeLabel"):::projected v4("?class"):::projected v1("?classLabel"):::projected v5("?p"):::projected v6("?statement") v3("?w"):::projected v2("?wLabel"):::projected a1((" ")) a2((" ")) c2(["bd:serviceParam"]):::iri c6(["wd:Q105757481"]):::iri c4(["de,en"]):::literal c9(["wd:Q98270496"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P31"--> c9 v5 --"p:P1416"--> v6 v6 --"p:statement/P1416"--> v3 v3 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P3831".-> v7 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P463"--> c6 v3 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> v4 end union0r <== or ==> union0l end bind0[/"if(not bound(?affiliationType),'Vereinsmitglied',?affiliationTypeLabel)"/] v7 --o bind0 v8 --o bind0 bind0 --as--o v8