What is {instance of} of {magnesium} that is {followed by} is {aluminium} ?
What Magnesium element comes after Aluminum?
Which is the next Magnesium element that is followed after Aluminium?
SELECT ?q WHERE { ?m property:followed_by resource:aluminium . ?m rdf:type ?q . resource:magnesium rdf:type ?m }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q660> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P31> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P156> <http://wikidata.dbpedia.org/resource/Q663>
} 

SELECT ?obj WHERE { wd:Q660 p:P31 ?s . ?s ps:P31 ?obj . ?s pq:P156 wd:Q663 }