query-9777e40f34e2049e025c60d169810e1b
Propertiesinstance of (P31)facet of (P1269)PM20 folder ID (P4293)PM20 geo code (P8483)number of works accessible online (P5592)series ordinal (P1545)
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select ?geo ?geoLabel ?geoCode ?folderCount ?docCount
where {
{
select ?geo (count(*) as ?folderCount) (sum(?folderDocCount) as ?docCount)
where {
?item wdt:P31 wd:Q91257459 ;
wdt:P1269 ?geo .
# document counts
optional {
?item p:P4293 ?statement2 .
?statement2 pq:P5592 ?folderDocCount .
filter(isLiteral(?folderDocCount))
}
}
group by ?geo
}
optional {
?geo p:P8483 ?statement3 .
?statement3 ps:P8483 ?geoCode ;
pq:P1545 ?sortCode .
}
service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en". }
}
order by ?sortCode
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?docCount"):::projected
v6("?folderCount"):::projected
v2("?folderDocCount")
v4("?geo"):::projected
v9("?geoCode"):::projected
v3("?item")
v1("?sortCode")
v5("?statement2")
v8("?statement3")
c10(["bd:serviceParam"]):::iri
c12(["#91;AUTO_LANGUAGE#93;, en"]):::literal
c2(["wd:Q91257459"]):::iri
v3 --"p:direct/P31"--> c2
v3 --"p:direct/P1269"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:P4293".-> v5
v5 --"p:qualifier/P5592"--> v2
end
bind2[/"count(*)"/]
bind2 --as--o v6
bind3[/"sum(?folderDocCount)"/]
v2 --o bind3
bind3 --as--o v7
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:P8483".-> v8
v8 --"p:statement/P8483"--> v9
v8 --"p:qualifier/P1545"--> v1
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end