query-2cefa4a0bf62ffaf2687094df2adaef2
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
- https://query.wikidata.org/sparql
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" }
}