query-db19fc98577c086bb88eb4457639bcb6
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?population ?area (?density_m2 * 1000000 AS ?density) {
  ?item wdt:P1082 ?population;
        wdt:P31/wdt:P279* wd:Q515;
        p:P2046 [ a wikibase:BestRank; psn:P2046/wikibase:quantityAmount ?area_in_m2 ] .
  BIND( ?population / ?area_in_m2 AS ?density_m2 ) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
} ORDER BY DESC(?density)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?area_in_m2")
  v6("?density")
  v5("?density_m2"):::projected 
  v2("?item"):::projected 
  v3("?population"):::projected 
  a1((" "))
  a2((" "))
  a3((" "))
  c6(["wikibase:BestRank"]):::iri 
  c13(["en"]):::literal 
  c11(["bd:serviceParam"]):::iri 
  c4(["wd:Q515"]):::iri 
  v2 --"p:direct/P1082"-->  v3
  v2 --"p:direct/P31"-->  a1
  a1 --"p:direct/P279"-->  c4
  a2 --"a"-->  c6
  a2 --"p:statement/value-normalized/P2046"-->  a3
  a3 --"wikibase:quantityAmount"-->  v4
  v2 --"p:P2046"-->  a2
  bind0[/"?population / ?area_in_m2"/]
  v3 --o bind0
  v4 --o bind0
  bind0 --as--o v5
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c11 --"wikibase:language"-->  c13
  end
  bind1[/"?density_m2 * '1000000^^xsd:integer'"/]
  v5 --o bind1
  bind1 --as--o v6