query-85bd34b98e5a687db5834497a515dd7f
Oldest institution in each country that acts as a library
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 DISTINCT ?countryLabel ?library ?libraryLabel (YEAR(?earliest) as ?year) WHERE {
{ SELECT ?country (MIN(?inception) as ?earliest) WHERE {
?library wdt:P31/wdt:P279? wd:Q7075 ; wdt:P131?/wdt:P17 ?country; wdt:P571 ?inception
} GROUP BY ?country }
?library wdt:P31/wdt:P279? wd:Q7075 ; wdt:P131?/wdt:P17 ?country; wdt:P571 ?earliest.
MINUS {?country wdt:P576 []} # Exclude abolished countries like the Austrian Empire
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?countryLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?country")
v1("?countryLabel"):::projected
v5("?earliest"):::projected
v4("?inception")
v2("?library"):::projected
v6("?year")
a5((" "))
a1((" "))
a2((" "))
a3((" "))
a4((" "))
c2(["wd:Q7075"]):::iri
c9(["bd:serviceParam"]):::iri
c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"wdt:P31"--> a1
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
a1 --"wdt:P279"--> c2
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
end
union0r <== or ==> union0l
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P131"--> a2
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
end
union1r <== or ==> union1l
end
a2 --"wdt:P17"--> v3
v2 --"wdt:P571"--> v4
bind1[/"min(?inception)"/]
v4 --o bind1
bind1 --as--o v5
v2 --"wdt:P31"--> a3
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
a3 --"wdt:P279"--> c2
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
end
union2r <== or ==> union2l
end
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P131"--> a4
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
end
union3r <== or ==> union3l
end
a4 --"wdt:P17"--> v3
v2 --"wdt:P571"--> v5
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
v3 --"wdt:P576"--> a5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end
bind3[/"year-from-dateTime(?earliest)"/]
v5 --o bind3
bind3 --as--o v6