query-60e85097da86b3596937ad3ebfa0a431
Twitter handles for Olympianshello! I've had a go at trying to run a query to pick out Olympians who use(d) Twitter, but my output isn't quite right. All I need is their Olympic/Olympedia ID and their Twitter handle. the following query brings back their wikidata ID and the name of the Olympian. it's been some years since I've used SQL - I'm missing something really obvious! P2002 is the Twitter handle and P8286 is their Olympic ID. Please can someone help when they have a moment? thank you
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
{
SELECT DISTINCT ?item WHERE {
?item p:P2002 ?statement0.
?statement0 (ps:P2002) _:anyValueP2002.
?item p:P8286 ?statement1.
?statement1 (ps:P8286) _:anyValueP8286.
}
LIMIT 100
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?item"):::projected
v2("?statement0")
v3("?statement1")
a1((" "))
a2((" "))
c2(["bd:serviceParam"]):::iri
c4(["#91;AUTO_LANGUAGE#93;"]):::literal
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v1 --"p:P2002"--> v2
v2 --"p:statement/P2002"--> a1
v1 --"p:P8286"--> v3
v3 --"p:statement/P8286"--> a2