query-4ee40a4a5e0c64a81e19a389c8564066
Mastodon accounts per country
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT
?mastodons
(CONCAT("#country/", SUBSTR(STR(?country), 32), "/mastodon") AS ?mastodonsUrl)
?country ?countryLabel
(CONCAT("#country/", SUBSTR(STR(?country), 32)) AS ?countryUrl)
?example_mastodon
WHERE {
{
SELECT
(COUNT(*) AS ?mastodons)
?country
(SAMPLE(?mastodon) AS ?example_mastodon)
WHERE {
[] wdt:P4033 ?mastodon ;
(wdt:P108| wdt:P1416)? / wdt:P159? / wdt:P17 ?country .
}
GROUP BY ?country
} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?mastodons)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?country"):::projected
v6("?countryUrl")
v4("?example_mastodon"):::projected
v2("?mastodon")
v4("?mastodons"):::projected
v5("?mastodonsUrl")
a1((" "))
a2((" "))
a3((" "))
c7(["bd:serviceParam"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
a1 --"wdt:P4033"--> v2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
a1 --"wdt:P1416"--> a2
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
a1 --"wdt:P108"--> a2
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
end
union0r <== or ==> union0l
end
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
a2 --"wdt:P159"--> a3
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
end
union2r <== or ==> union2l
end
a3 --"wdt:P17"--> v3
bind2[/"count(*)"/]
bind2 --as--o v4
bind3[/"sample(?mastodon)"/]
v2 --o bind3
bind3 --as--o v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end
bind4[/"concat('#country/',substring(str(?country),'32^^xsd:integer'),'/mastodon')"/]
v3 --o bind4
bind4 --as--o v5
bind5[/"concat('#country/',substring(str(?country),'32^^xsd:integer'))"/]
v3 --o bind5
bind5 --as--o v6