What is {position held} of {Bonar Law} that is {elected in} is {UK Parliamentary by-election} ?
Bonar Law held what position in UK Parliamentary by election?
What is the position held by Bonar Law who is elected in UK Parliamentary by-election?
SELECT ?l WHERE { ?p property:position_held ?l . ?p property:elected_in resource:UK_Parliamentary_by-election . resource:Bonar_Law property:position_held ?p }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q166663> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P39> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P2715> <http://wikidata.dbpedia.org/resource/Q7864918>
} 

SELECT ?obj WHERE { wd:Q166663 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P2715 wd:Q7864918 }