query-c7f7c507e3ab4160617444edcad3a0f5
Incorrect results looking for senate seats?. I came up with the following query (Q101500234)United States Senate seat qualifiers for United States senators are not subclasses of (P768)electoral district Hey there, I was trying to check which
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 ?sen ?senLabel ?stmt ?seat WHERE {
?sen p:P39 ?stmt.
?stmt ps:P39 wd:Q4416090;
pq:P2937 ?term;
pq:P768 ?seat.
FILTER(NOT EXISTS {
?seat (wdt:P31/p:P279) [ ps:P279 wd:Q101500234 ].
})
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?seat"):::projected
v2("?sen"):::projected
v3("?stmt"):::projected
v4("?term")
a2((" "))
a1((" "))
c2(["wd:Q101500234"]):::iri
c11(["bd:serviceParam"]):::iri
c7(["wd:Q4416090"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0a1 --"p:statement/P279"--> e0c2
e0v1 --"p:direct/P31"--> e0a2
e0a2 --"p:P279"--> e0a1
e0v1("?seat"):::projected
e0a2((" ")):::projected
e0a1((" ")):::projected
e0c2(["wd:Q101500234"]):::iri
end
f0--EXISTS--> f0e0
f0 --> a1
f0 --> c1
f0 --> c2
f0 --> v1
f0 --> c3
f0 --> a2
f0 --> c4
a1 --"p:statement/P279"--> c2
v1 --"p:direct/P31"--> a2
a2 --"p:P279"--> a1
v2 --"p:P39"--> v3
v3 --"p:statement/P39"--> c7
v3 --"p:qualifier/P2937"--> v4
v3 --"p:qualifier/P768"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end