0

I want to use a Sparql query to find the rank (Trump 45, Obama 44...) from Wikidata. This Property does not seem to exist for the entity President of the United States (Q11696). Does anyone have an idea how to solve this problem?

Thanks!

1 Answers1

1

Looking at the existing data is your friend...at least I looked at e.g. Gerald Ford and found that there is a "position held" statement which itself has a "series ordinal" value:

SELECT ?p ?pLabel  ?rank WHERE {
  # presidents of US
  wd:Q30 (p:P6/ps:P6) ?p.
  # get their "position held" statement (to "President of the United States of America" only)
  ?p p:P39 ?position_held_statement .
  ?position_held_statement ps:P39 wd:Q11696 .
  ?position_held_statement pq:P1545 ?rank . # here is the rank (series ordinal)

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
UninformedUser
  • 8,397
  • 1
  • 14
  • 23