What is the {municipality of Catalonia} with the {MAX(population)} whose {located in the administrative territorial entity} is {Bages}  ?
In Bages, which municipality of Catalonia has the highest population?
What municipality of Catalonia, that is located in Bages,  is the most populated?
SELECT ?z WHERE { ?z rdf:type ontology:municipality_of_Catalonia . ?z property:located_in_the_administrative_territorial_entity resource:Bages . ?z property:population ?u }
select ?ent where {
?ent <http://www.wikidata.org/entity/P31> <http://wikidata.dbpedia.org/resource/Q33146843>.

?statement1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?ent .
?statement1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P1082>.
?statement1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj1.

?statement2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?ent .
?statement2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P131> .
?statement2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://wikidata.dbpedia.org/resource/Q15346> .

}
ORDER BY DESC(?obj1)
LIMIT 5
select ?ent where { ?ent wdt:P31 wd:Q33146843 . ?ent wdt:P1082 ?obj . ?ent wdt:P131 wd:Q15346 } ORDER BY DESC(?obj)LIMIT 5 
Manresa Sant Joan de Vilatorrada Sant Vicenç de Castellet Sant Fruitós de Bages Santpedor