query-0b4d2bb0c81e63c07d9d4bdb84bef617
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#title:P8034 by number of external identifiers (group 15-25, 26+)
#defaultView:BubbleChart
SELECT ?group (SUM(?count) AS ?count_group) #(SAMPLE(?sampl) AS ?sample)
WHERE
{
{
SELECT ?ids (COUNT(DISTINCT ?item) AS ?count) #(SAMPLE(?item) AS ?sampl)
WHERE
{
?item wdt:P8034 ?id .
?item wikibase:identifiers ?ids .
}
GROUP BY ?ids
} BIND( IF(?ids < 16, CONCAT("0",STR(?ids)), #zero added for sorting by group
IF(?ids < 26, "16-25", "26+"))
AS ?group)
}
GROUP BY ?group
ORDER BY ?group
Query found at
- https://www.wikidata.org/wiki/User:Ep%C3%ACdosis/Queries
- https://www.wikidata.org/wiki/User:Ep%C3%ACdosis/sandbox
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?count"):::projected
v6("?count_group")
v6("?group"):::projected
v3("?id")
v4("?ids")
v2("?item")
v2 --"wdt:P8034"--> v3
v2 --"wikibase:identifiers"--> v4
bind1[/"count(?item)"/]
v2 --o bind1
bind1 --as--o v5
bind2[/"if(?ids < '16^^xsd:integer',concat('0',str(?ids)),if(?ids < '26^^xsd:integer','16-25','26+'))"/]
v4 --o bind2
bind2 --as--o v6
bind4[/"sum(?count)"/]
v5 --o bind4
bind4 --as--o v6