query-445b356dedba6667e4ee08761f09ebb3

rq turtle/ttl

TODO

Use at

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 ?countryLabel (COUNT(?item) AS ?number_of_objects) (SUM(?length) AS ?sum_length_meters) (ROUND(SUM(?length)/COUNT(?item)) AS ?average_length_meters) {
  ?item wdt:P31/wdt:P279* wd:Q2354973 . # to get all subclasses (types) of tunnels, change this to wd:Q44377 .
  ?item wdt:P17 ?country .
  ?item p:P2043 [ psn:P2043  [ wikibase:quantityAmount ?length ] ] .  # psn translates all values for length to a common unit, i.e. meters
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?countryLabel
ORDER BY DESC(?number_of_objects) ?countryLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?average_length_meters") v4("?country") v2("?countryLabel"):::projected v3("?item"):::projected v5("?length"):::projected v6("?number_of_objects") v6("?sum_length_meters") a1((" ")) a3((" ")) a2((" ")) c9(["bd:serviceParam"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["wd:Q2354973"]):::iri v3 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 v3 --"p:direct/P17"--> v4 a2 --"wikibase:quantityAmount"--> v5 a3 --"p:statement/value-normalized/P2043"--> a2 v3 --"p:P2043"--> a3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind4[/"count(?item)"/] v3 --o bind4 bind4 --as--o v6 bind5[/"sum(?length)"/] v5 --o bind5 bind5 --as--o v6 bind6[/"numeric-round( / )"/] null --o bind6 null --o bind6 bind6 --as--o v7