query-4c28bfb04d27ba5af72b8aebd8b98453
Fast but weird
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
SELECT ?item (SAMPLE(?instanceFilter) AS ?instanceFilter) (COUNT(?link) AS ?links) WHERE {
# apply territory filter (Milano)
?item (wdt:P131*) wd:Q490.
# item must be an instance of (of any subclass of) something we want
?item wdt:P31/wdt:P279* ?instanceFilter.
VALUES (?instanceFilter) {
# educational institution
(wd:Q2385804)
# park
(wd:Q22698)
}
# exclude items with coordinates or an headquarter or that are deprecated
MINUS {
?item wdt:P625|wdt:P159|wdt:P576 ?unusedinfo.
}
#OPTIONAL {
# links to Wikimedia projects
?link schema:about ?item.
#}
}
# group by item so we can count their links
GROUP BY ?item
ORDER BY DESC(?links)
LIMIT 100
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?instanceFilter"):::projected
v2("?item"):::projected
v5("?link"):::projected
v6("?links")
v4("?unusedinfo")
a1((" "))
c2(["wd:Q490"]):::iri
v2 --"wdt:P131"--> c2
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> v6
bind0[/VALUES ?instanceFilter/]
bind0-->v6
bind00(["wd:Q2385804"])
bind00 --> bind0
bind01(["wd:Q22698"])
bind01 --> bind0
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
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;
v2 --"wdt:P576"--> v4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P159"--> v4
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P625"--> v4
end
union0r <== or ==> union0l
end
end
v5 --"schema:about"--> v2
bind4[/"sample(?instanceFilter)"/]
v6 --o bind4
bind4 --as--o v6
bind5[/"count(?link)"/]
v5 --o bind5
bind5 --as--o v6