Reputation: 14435
I'm using the following SPARQL query to get a list of all US presidents together with the start and end dates of their presidency:
SELECT ?person $personLabel $start $end
WHERE {
?person wdt:P39 wd:Q11696.
?person p:P39 ?statement.
?position_held_statement ps:P39 wd:Q11696.
?statement pq:P580 ?start.
?statement pq:P582 ?end
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC($start)
Why does it return so many rows?
EDIT: I know I can use SELECT DISTINCT
to get only distinct results, but I want to learn how I can find out the reason for the duplicates. Moreover, there are entries which state that Barack Obama's presidency lasted from January 2009 to January 2017, while others state his two terms separately.
Upvotes: 2
Views: 113
Reputation: 9472
You have ?position_held_statement
there. That should be ?statement
.
When you unexpectedly have a lot of results in SPARQL, it’s usually because of mismatched variable names turning what should be a join into a cartesian product.
Upvotes: 2