query-5ff634519f73bcf4ca69f4fe435ee3e2
Here the "group by" at the end is all the variables you want to leave unchanged, and the SAMPLE command tells it to only select one value from ?image. You'll see that the number of results is now exactly what you expect. (Depending on what you are doing with the data, it may also be possible to just accept the duplicate lines...) for the constituencies to help link into another dataset. (P625)coordinate location and (P836)GSS code (2011) We can also start using the variables we have identified to obtain data from elsewhere in the graph. For example, we might want to find the
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 DISTINCT ?person ?personLabel ?partyLabel ?seatLabel ?coordinates ?gss_code WHERE
{
?person wdt:P31 wd:Q5 . ?person p:P39 ?ps .
?ps ps:P39 ?term . ?term wdt:P279 wd:Q16707842 .
?ps pq:P580 ?start . ?ps pq:P4100 ?party . ?ps pq:P768 ?seat .
FILTER NOT EXISTS { ?ps pq:P582 ?end } .
?seat wdt:P625 ?coordinates .
?seat wdt:P836 ?gss_code .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?coordinates"):::projected
v2("?end")
v9("?gss_code"):::projected
v6("?party")
v3("?person"):::projected
v1("?ps")
v7("?seat")
v5("?start")
v4("?term")
c7(["wd:Q16707842"]):::iri
c16(["en"]):::literal
c14(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"p:qualifier/P582"--> e0v2
e0v2("?end"):::projected
e0v1("?ps"):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> v2
v1 --"p:qualifier/P582"--> v2
v3 --"p:direct/P31"--> c3
v3 --"p:P39"--> v1
v1 --"p:statement/P39"--> v4
v4 --"p:direct/P279"--> c7
v1 --"p:qualifier/P580"--> v5
v1 --"p:qualifier/P4100"--> v6
v1 --"p:qualifier/P768"--> v7
v7 --"p:direct/P625"--> v8
v7 --"p:direct/P836"--> v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c14 --"wikibase:language"--> c16
end