query-a1d9ada214e83b2bfde4bf175029aec9

rq turtle/ttl

TODO

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?item ?caLabel ?esLabel (group_concat(distinct ?typeLabel) as ?typeLabel) 
 where {
   { select distinct ?item where {
  ?item wdt:P131/wdt:P131* wd:Q5705 .                       # item is located in Catalonia
   } 
 }.
  ?item wdt:P31/wdt:P279* wd:Q486972 .                      # item is a human settlement or subclass of
#  ?item wdt:P31 wd:Q515                                    # item is a city
#  ?item wdt:P31 https://www.wikidata.org/wiki/Q33146843 .  # item is a municipality of Catalonia
  ?item wdt:P31 ?type. 
  optional { ?type rdfs:label ?typeLabel. filter(lang(?typeLabel)="es") } #get the P31 label
  optional { ?item rdfs:label ?esLabel. filter(lang(?esLabel)="es") }
  optional { ?item rdfs:label ?caLabel. filter(lang(?caLabel)="ca") }                             
} group by ?item ?esLabel ?caLabel order by ?caLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?caLabel"):::projected v2("?esLabel"):::projected v4("?item"):::projected v5("?type") v6("?typeLabel"):::projected a1((" ")) a2((" ")) c4(["wd:Q5705"]):::iri c7(["wd:Q486972"]):::iri v4 --"wdt:P131"--> a1 a1 --"wdt:P131"--> c4 v4 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c7 v4 --"wdt:P31"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."rdfs:label".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."rdfs:label".-> v2 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."rdfs:label".-> v1 end bind1[/"?typeLabel"/] v6 --o bind1 bind1 --as--o v6