Skip to content

addQueryDocumentation #54

@WolfgangFahl

Description

@WolfgangFahl

refactor from test_queries as a standard function and fix: values table below while at it.

Ten largest cities of the world

Wikidata SPARQL query showing the 10 most populated cities of the world using the million city class Q1637706 for selection

query

# Ten Largest cities of the world 
# WF 2021-08-23
# see also http://wiki.bitplan.com/index.php/PyLoDStorage#Examples
# see also https://github.com/WolfgangFahl/pyLoDStorage/issues/46
SELECT DISTINCT ?city ?cityLabel ?population ?country ?countryLabel 
WHERE {
  VALUES ?cityClass { wd:Q1637706}.
  ?city wdt:P31 ?cityClass .
  ?city wdt:P1082 ?population .
  ?city wdt:P17 ?country .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
ORDER BY DESC(?population)
LIMIT 10

try it!

result

city cityLabel population country countryLabel
Value(uri:'http://www.wikidata.org/entity/Q1353') Value(literal:'Delhi') Value(literal:'26495000') Value(uri:'http://www.wikidata.org/entity/Q668') Value(literal:'India')
Value(uri:'http://www.wikidata.org/entity/Q8686') Value(literal:'Shanghai') Value(literal:'24870895') Value(uri:'http://www.wikidata.org/entity/Q148') Value(literal:"People's Republic of China")
Value(uri:'http://www.wikidata.org/entity/Q956') Value(literal:'Beijing') Value(literal:'21710000') Value(uri:'http://www.wikidata.org/entity/Q148') Value(literal:"People's Republic of China")
Value(uri:'http://www.wikidata.org/entity/Q1354') Value(literal:'Dhaka') Value(literal:'16800000') Value(uri:'http://www.wikidata.org/entity/Q902') Value(literal:'Bangladesh')
Value(uri:'http://www.wikidata.org/entity/Q1156') Value(literal:'Mumbai') Value(literal:'15414288') Value(uri:'http://www.wikidata.org/entity/Q668') Value(literal:'India')
Value(uri:'http://www.wikidata.org/entity/Q8660') Value(literal:'Karachi') Value(literal:'14910352') Value(uri:'http://www.wikidata.org/entity/Q843') Value(literal:'Pakistan')
Value(uri:'http://www.wikidata.org/entity/Q8673') Value(literal:'Lagos') Value(literal:'14862000') Value(uri:'http://www.wikidata.org/entity/Q1033') Value(literal:'Nigeria')
Value(uri:'http://www.wikidata.org/entity/Q406') Value(literal:'Istanbul') Value(literal:'14657434') Value(uri:'http://www.wikidata.org/entity/Q43') Value(literal:'Turkey')
Value(uri:'http://www.wikidata.org/entity/Q1490') Value(literal:'Tokyo') Value(literal:'14049146') Value(uri:'http://www.wikidata.org/entity/Q17') Value(literal:'Japan')
Value(uri:'http://www.wikidata.org/entity/Q16572') Value(literal:'Guangzhou') Value(literal:'14043500') Value(uri:'http://www.wikidata.org/entity/Q148') Value(literal:"People's Republic of China")

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions