query-a504a0a6bbb445602e7c8cbbfd53ed7e

rq turtle/ttl

Compter des éléments avec une hiérarchie) les unes des autres. (P279)subclass of ) est trompeur parce qu'on ne voit pas que certaines occurrences sont des sous-classes ((P31)instance of Compter des éléments par nature (L'idée c'est d'avoir un processus en deux étapes avec deux requêtes SELECT.

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#>
SELECT  ?category ?categoryLabel (COUNT (?item) as ?count) WHERE {
  SELECT DISTINCT ?item ?category ?categoryLabel WHERE {
  VALUES ?category {
    wd:Q484170
    wd:Q2659904
    wd:Q163740
  }
  ?item wdt:P31 ?instance_of;
    wdt:P3206 ?datagouvid.
  ?instance_of (wdt:P279*) ?category.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}
}
GROUP BY ?category ?categoryLabel
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?category"):::projected v6("?count") v5("?datagouvid") v4("?instance_of") v3("?item"):::projected c5(["bd:serviceParam"]):::iri c7(["fr"]):::literal bind0[/VALUES ?category/] bind0-->v2 bind00(["wd:Q484170"]) bind00 --> bind0 bind01(["wd:Q2659904"]) bind01 --> bind0 bind02(["wd:Q163740"]) bind02 --> bind0 v3 --"wdt:P31"--> v4 v3 --"wdt:P3206"--> v5 v4 --"wdt:P279"--> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end bind2[/"count(?item)"/] v3 --o bind2 bind2 --as--o v6