query-1e3e8b1ff74b8afd1d4bd700b88c3e65
Count of items and statements about KC objects
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?collectionLabel ?items ?statements WHERE {
{SELECT ?collectionLabel (COUNT(?i) AS ?items) (SUM(?stat) AS ?statements) WHERE
{
?i wdt:P195 ?collection. ?collection wdt:P361 wd:Q63160499.
?i wikibase:statements ?stat
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?collectionLabel
} UNION {
SELECT ?collectionLabel (COUNT(?i) AS ?items) (SUM(?stat) AS ?statements)
WHERE
{?i wdt:P195 ?collection. ?collection wdt:P361 wd:Q63160499.
?i wikibase:statements ?stat
BIND ("Total" AS ?collectionLabel)
} GROUP BY ?collectionLabel
}
} ORDER BY ?collectionLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?collection")
v7("?collectionLabel"):::projected
v2("?i")
v7("?items"):::projected
v4("?stat")
v7("?statements"):::projected
c6(["bd:serviceParam"]):::iri
c3(["wd:Q63160499"]):::iri
c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P195"--> v3
v3 --"wdt:P361"--> c3
v2 --"wikibase:statements"--> v4
bind0[/"'Total'"/]
bind0 --as--o v7
bind3[/"count(?i)"/]
v2 --o bind3
bind3 --as--o v7
bind4[/"sum(?stat)"/]
v4 --o bind4
bind4 --as--o v7
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P195"--> v3
v3 --"wdt:P361"--> c3
v2 --"wikibase:statements"--> v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
end
bind7[/"count(?i)"/]
v2 --o bind7
bind7 --as--o v7
bind8[/"sum(?stat)"/]
v4 --o bind8
bind8 --as--o v7
end
union0r <== or ==> union0l
end