query-4c579879844a98f0d5f7cac9430dd631

rq turtle/ttl

top 50 for P31 and P279 of items using P496 SELECT ?class ?classLabel ?count ?use_as_Label { { SELECT ?class (COUNT() AS ?count) (wd:P31 as ?use_as_) { ?a wdt:P496 ?p ; wdt:P31 ?class} GROUP BY ?class ORDER BY DESC(?count) LIMIT 50 } UNION { SELECT ?class (COUNT() AS ?count) (wd:P279 as ?use_as_) { ?a wdt:P496 ?p ; wdt:P279 ?class} GROUP BY ?class ORDER BY DESC(?count) LIMIT 50 } SERVICE wikibase:label { bd:serviceParam wikibase:language "en,en" } } ORDER BY DESC(?count) ?class

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#top 50 for P31 and P279 of items using P496
SELECT ?class ?classLabel ?count ?use_as_Label
{   {   SELECT ?class (COUNT(*) AS ?count) (wd:P31 as ?use_as_)
        {   ?a  wdt:P496    ?p  ; wdt:P31   ?class}
        GROUP BY ?class ORDER BY DESC(?count) LIMIT 50
    }
    UNION
    {   SELECT ?class (COUNT(*) AS ?count) (wd:P279 as ?use_as_)
        {   ?a  wdt:P496    ?p  ; wdt:P279  ?class}
        GROUP BY ?class ORDER BY DESC(?count) LIMIT 50
    }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en,en" }
}
ORDER BY DESC(?count) ?class

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?a") v2("?class"):::projected v6("?count"):::projected v4("?p") v6("?use_as_") c5(["bd:serviceParam"]):::iri c7(["en,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P496"--> v4 v3 --"wdt:P279"--> v2 bind1[/"count(*)"/] bind1 --as--o v6 bind2[/"'wd:P279'"/] bind2 --as--o v6 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P496"--> v4 v3 --"wdt:P31"--> v2 bind4[/"count(*)"/] bind4 --as--o v6 bind5[/"'wd:P31'"/] bind5 --as--o v6 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end