query-0687c16c3a41d8b9806c63fec1d16123

rq turtle/ttl

y la variante de todos los municipios que sí existen:

Use at

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 DISTINCT ?item ?itemLabel ?c_digo_INE ?identificador_GeoNames WHERE {
  ?item (wdt:P31/(wdt:P279*)) wd:Q2074737.
  FILTER(NOT EXISTS { ?item wdt:P582 ?fecha_de_fin. })
  MINUS {
    ?item p:P31 ?statement.
    ?statement ps:P31 ?municipio;
      pq:P582 ?fechafin.
  }
  MINUS { ?item wdt:P31 wd:Q55863584. }
  MINUS { ?item wdt:P31 wd:Q19730508. }  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es". }
  OPTIONAL { ?item wdt:P772 ?c_digo_INE. }
  OPTIONAL { ?item wdt:P1566 ?identificador_GeoNames. }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?c_digo_INE"):::projected v2("?fecha_de_fin") v5("?fechafin") v7("?identificador_GeoNames"):::projected v1("?item"):::projected v4("?municipio") v3("?statement") a1((" ")) c4(["wd:Q2074737"]):::iri c8(["wd:Q55863584"]):::iri c9(["wd:Q19730508"]):::iri c13(["es"]):::literal c11(["bd:serviceParam"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:direct/P582"--> e0v2 e0v2("?fecha_de_fin"):::projected e0v1("?item"):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 v1 --"p:direct/P582"--> v2 v1 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v1 --"p:P31"--> v3 v3 --"p:statement/P31"--> v4 v3 --"p:qualifier/P582"--> v5 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v1 --"p:direct/P31"--> c8 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v1 --"p:direct/P31"--> c9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P772".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P1566".-> v7 end