query-24e0e79daf3f553bfeef29ebff1a5315
Elections without correct office contested SELECT ?item ?itemLabel ?office ?officeLabel (MIN(?pot) AS ?date) WHERE { ?item wdt:P31/wdt:P279 wd:Q22341275 . OPTIONAL { ?item wdt:P541 ?office } OPTIONAL { ?item wdt:P585 ?pot } MINUS { ?item wdt:P541/wdt:P279 wd:Q18607856 } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?item ?itemLabel ?office ?officeLabel ORDER BY ?date
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#>
# Elections without correct office contested
SELECT ?item ?itemLabel ?office ?officeLabel (MIN(?pot) AS ?date)
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q22341275 .
  OPTIONAL { ?item wdt:P541 ?office }
  OPTIONAL { ?item wdt:P585 ?pot }
  MINUS { ?item wdt:P541/wdt:P279* wd:Q18607856 }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?item ?itemLabel ?office ?officeLabel 
ORDER BY ?date
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?date")
  v2("?item"):::projected 
  v3("?office"):::projected 
  v4("?pot"):::projected 
  a1((" "))
  a2((" "))
  c3(["wd:Q22341275"]):::iri 
  c8(["bd:serviceParam"]):::iri 
  c6(["wd:Q18607856"]):::iri 
  c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal 
  v2 --"wdt:P31"-->  a1
  a1 --"wdt:P279"-->  c3
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."wdt:P541".->  v3
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."wdt:P585".->  v4
  end
  subgraph minus0["MINUS"]
    style minus0 stroke-width:6px,fill:pink,stroke:red;
    v2 --"wdt:P541"-->  a2
    a2 --"wdt:P279"-->  c6
  end
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c8 --"wikibase:language"-->  c10
  end
  bind2[/"min(?pot)"/]
  v4 --o bind2
  bind2 --as--o v5