I am new to SPARQL and Wikidata, and am trying to retrieve the following for the Hugo Award Winners:
- Work Title
- Author
- Year Won
I'm finding this surprisingly difficult.
I started off querying for all tuples linking to the award for best novel with a link type of "won by".
SELECT DISTINCT ?winner WHERE {
# P166: Award Recieved By
# Q103360: Hugo Award for Best Novel
?winner ps:P1346 wd:Q255032.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
This works, but when I add the title link from the winner, there's no data:
SELECT DISTINCT ?winner WHERE {
?winner ps:P1346 wd:Q255032.
OPTIONAL {
# P1476: Title
?winner wdt:P1476 ?title.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
What am I doing wrong? I've tried different namespaces, with little comprehension, and to no avail.
On the page for the Hugo winners, there's a section of winners: https://www.wikidata.org/wiki/Q255032#P1346
How is that generated? I tried to query that property and got back links to people (I think):
SELECT DISTINCT ?winner ?winnerLabel ?for WHERE {
# P166: winner
# Q103360: Hugo Award for Best Novel
wd:Q255032 wdt:P1346 ?winner.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
wdt:P166
as predicate? - UninformedUserwdt:P166
. But, to get the fields back have to have to add them to the SELECT part of course, i.e.SELECT DISTINCT ?winner ?winnerLabel ?titleLabel
- UninformedUser