query-9724660a7d54bbe594b9befbf33c42e1
Municipalities with most shared bordersI'm trying to show which municipality has more shared borders, but it gives a strange aggregation, with way more numbers than the real one. What is wrong?
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 (SAMPLE(?mugakideak) as ?mugakideak) ?mugakideakLabel (COUNT(?udalerria) as ?count) WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "eu,en". }
{ ?udalerria wdt:P31 wd:Q2074737. }
UNION
{ ?udalerria wdt:P31 wd:Q484170. }
?udalerria ((wdt:P131*)/^wdt:P527) wd:Q47588.
?udalerria wdt:P47 ?mugakideak.
}
GROUP BY ?mugakideakLabel
ORDER by DESC(?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?count")
v4("?mugakideak"):::projected
v2("?udalerria"):::projected
a1((" "))
c4(["eu,en"]):::literal
c6(["wd:Q2074737"]):::iri
c2(["bd:serviceParam"]):::iri
c9(["wd:Q47588"]):::iri
c7(["wd:Q484170"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P31"--> c7
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P31"--> c6
end
union0r <== or ==> union0l
end
v2 --"wdt:P131"--> a1
c9 --"wdt:P527"--> a1
v2 --"wdt:P47"--> v4
bind2[/"sample(?mugakideak)"/]
v4 --o bind2
bind2 --as--o v4
bind3[/"count(?udalerria)"/]
v2 --o bind3
bind3 --as--o v4