query-5840121d6ad95c028c9bf42589a16675
Municipalities of Catalonia. I need to search both rank and preferred statements. is the some alternative to this fact: ""# (wdt: properties use only statements of "preferred" rank if any, usually meaning "current population")"? (Q2074737)municipality of Spain Hi! I looking for a list of all municipalities of Catalonia. I did a query but it doesn't work well because some municipalities have statements with a "preferred rank" defined and their are not
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 ?item ?comarcaLabel ?population WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item wdt:P31/wdt:P279* wd:Q2074737;
wdt:P131 ?comarca;
p:P1082 [ ps:P1082 ?population; pq:P585 ?data].
?comarca wdt:P31 wd:Q937876.
FILTER(YEAR(?data) = 2017).
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?comarca")
v1("?data")
v2("?item"):::projected
v4("?population"):::projected
a1((" "))
a2((" "))
c8(["wd:Q2074737"]):::iri
c3(["bd:serviceParam"]):::iri
c5(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c13(["wd:Q937876"]):::iri
f0[["year-from-dateTime(?data) = '2017^^xsd:integer'"]]
f0 --> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c3 --"wikibase:language"--> c5
end
v2 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c8
v2 --"p:direct/P131"--> v3
a2 --"p:statement/P1082"--> v4
a2 --"p:qualifier/P585"--> v1
v2 --"p:P1082"--> a2
v3 --"p:direct/P31"--> c13