query-2cefa4a0bf62ffaf2687094df2adaef2

rq turtle/ttl

KOS types with number of instances and additional numbers SELECT ?item ?itemLabel ?broader ?parents ?size ?sites { {
# number of additional superclasses SELECT ?item (count(distinct ?parent)-1 as ?parents) { ?item wdt:P279 wd:Q6423319 OPTIONAL { ?item wdt:P279 ?parent } } GROUP BY ?item
} { # number of instances SELECT ?item (count(distinct ?element) as ?size) { ?item wdt:P279
wd:Q6423319 OPTIONAL { ?element wdt:P31 ?item } } GROUP BY ?item
} { # number of sitelinks SELECT ?item (count(distinct ?site) as ?sites) { ?item wdt:P279* wd:Q6423319 OPTIONAL { ?site schema:about ?item } } GROUP BY ?item
} OPTIONAL { ?item wdt:P279 ?broader } SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# KOS types with number of instances and additional numbers
SELECT ?item ?itemLabel ?broader ?parents ?size ?sites {
  {  
    # number of additional superclasses
    SELECT ?item (count(distinct ?parent)-1 as ?parents) {
      ?item wdt:P279* wd:Q6423319
      OPTIONAL { ?item wdt:P279 ?parent }
    } GROUP BY ?item    
  } { 
    # number of instances
    SELECT ?item (count(distinct ?element) as ?size) {
     ?item wdt:P279* wd:Q6423319
     OPTIONAL { ?element wdt:P31 ?item }
    } GROUP BY ?item      
  } { 
    # number of sitelinks
    SELECT ?item (count(distinct ?site) as ?sites) {
      ?item wdt:P279* wd:Q6423319
      OPTIONAL { ?site schema:about ?item }
    } GROUP BY ?item    
  }
  OPTIONAL { ?item wdt:P279 ?broader }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?_anon_42b5416610844a34809f33a099ae9de164923") v9("?broader"):::projected v5("?element") v1("?item"):::projected v2("?parent") v4("?parents"):::projected v7("?site") v8("?sites"):::projected v6("?size"):::projected c6(["bd:serviceParam"]):::iri c8(["en"]):::literal c2(["wd:Q6423319"]):::iri v1 --"wdt:P279"--> c2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P279".-> v2 end bind1[/"count(?parent)"/] v2 --o bind1 bind1 --as--o v3 bind2[/" + '-1^^xsd:integer'"/] null --o bind2 bind2 --as--o v4 v1 --"wdt:P279"--> c2 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P31".-> v1 end bind4[/"count(?element)"/] v5 --o bind4 bind4 --as--o v6 v1 --"wdt:P279"--> c2 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."schema:about".-> v1 end bind6[/"count(?site)"/] v7 --o bind6 bind6 --as--o v8 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P279".-> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end