query-197beb93af8214dffa482f0917b03381
Finding number of items with time zone specified, grouped by 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 ?country ?countryLabel ?zones ?items (ROUND((100*?items)/?zones)/100 AS ?obsession) (ROUND((100000*?items)/?area)/100 AS ?itemdensity) WHERE {
{
SELECT DISTINCT ?country (COUNT(DISTINCT ?zone) AS ?zones) (COUNT(DISTINCT ?item) AS ?items) WHERE {
?item wdt:P421 ?zone.
?item wdt:P17 ?country.
}
GROUP BY ?country
}
?country wdt:P2046 ?area.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC(?obsession)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?area"):::projected
v4("?country"):::projected
v2("?item")
v8("?itemdensity")
v6("?items"):::projected
v8("?obsession")
v3("?zone")
v5("?zones"):::projected
c5(["bd:serviceParam"]):::iri
c7(["en"]):::literal
v2 --"wdt:P421"--> v3
v2 --"wdt:P17"--> v4
bind2[/"count(?zone)"/]
v3 --o bind2
bind2 --as--o v5
bind3[/"count(?item)"/]
v2 --o bind3
bind3 --as--o v6
v4 --"wdt:P2046"--> v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end
bind4[/"numeric-round('100^^xsd:integer' * ?items / ?zones) / '100^^xsd:integer'"/]
v6 --o bind4
v5 --o bind4
bind4 --as--o v8
bind5[/"numeric-round('100000^^xsd:integer' * ?items / ?area) / '100^^xsd:integer'"/]
v6 --o bind5
v7 --o bind5
bind5 --as--o v8