query-c23ffe00dd6cbecd3be950b220578d8f
Count of items by KTop class
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 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 (COUNT(DISTINCT(?item)) AS ?count) ?class ?classLabel ?subjectLabel WHERE {
?class p:P195 ?coll_stmt .
?coll_stmt ps:P195 wd:Q56753539 . # KTop
?coll_stmt pq:P1545 ?sort_key .
?class wdt:P921 ?subject .
?item wdt:P195 ?class .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?sort_key ?class ?classLabel ?subjectLabel
ORDER BY ?sort_key
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?class"):::projected
v3("?coll_stmt")
v6("?count")
v5("?item"):::projected
v1("?sort_key")
v4("?subject")
c8(["bd:serviceParam"]):::iri
c3(["wd:Q56753539"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"p:P195"--> v3
v3 --"p:statement/P195"--> c3
v3 --"p:qualifier/P1545"--> v1
v2 --"p:direct/P921"--> v4
v5 --"p:direct/P195"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end
bind1[/"count(?item)"/]
v5 --o bind1
bind1 --as--o v6