How to find cities with more than X population in a certain country

Deadly 提交于 2019-12-04 10:55:34

Simple:

SELECT ?resource ?value
WHERE { 
   ?resource a <http://dbpedia.org/class/yago/CitiesAndTownsInDenmark> .
   ?resource <http://dbpedia.org/property/populationTotal> ?value .
   FILTER (?value > 100000)
}
ORDER BY ?resource ?value

In other words: find all the things with type "City or Town in Denmark", and find their populations. You can abbreviate the query, avoiding repetition of 'resource', using ';' rather than '.':

?resource a <http://dbpedia.org/class/yago/CitiesAndTownsInDenmark> ;
          <http://dbpedia.org/property/populationTotal> ?value .

(If you're used to SQL '.' is essentially a natural join: you have ?resource on each side, so join on that value)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!