Question: What office position did James K. Polk hold from April 1, 1789 before he was President?
Answer(s):
answer: Speaker of the United States House of Representatives

SPARQL query:
#MANUAL SPARQL
PREFIX ns: <http://rdf.freebase.com/ns/>
SELECT DISTINCT ?x
WHERE {
  {
    SELECT ?pFrom 
    WHERE {
      ns:m.042f1 ns:government.politician.government_positions_held ?y . # James K. Polk
      ?y ns:government.government_position_held.office_position_or_title ?x ; 
         ns:government.government_position_held.basic_title ns:m.060c4 ; # President
         ns:government.government_position_held.from ?pFrom .
    }
  }
  ns:m.042f1 ns:government.politician.government_positions_held ?y . # James K. Polk
  ?y ns:government.government_position_held.office_position_or_title ?x ; 
     ns:government.government_position_held.from ?from .
  
  FILTER(xsd:dateTime(?pFrom) - xsd:dateTime(?from) > 0)?x ns:government.government_office_or_title.office_holders ?c .
?c ns:government.government_position_held.from "1789-04-01"^^xsd:dateTime . 
}