query-fa04dbafc54f3d93534cd342b6b6bc4b

rq turtle/ttl

title: rivers by length SELECT ?item ?itemLabel ?length_in_m ?length ?unitLabel ?lowerbound ?upperbound ?precision ?length2 ?conversion WHERE { ?item wdt:P31/wdt:P279* wd:Q47521. # bach ?item p:P2043 ?stmnode. # length ?stmnode psv:P2043 ?valuenode. ?valuenode wikibase:quantityAmount ?length. ?valuenode wikibase:quantityUnit ?unit. optional {?valuenode wikibase:quantityLowerBound ?lowerbound. ?valuenode wikibase:quantityUpperBound ?upperbound. BIND((?upperbound-?lowerbound)/2 AS ?precision). BIND(IF(?precision=0, ?length, (CONCAT(str(?length), "±", str(?precision)))) AS ?length2). }

# conversion to SI unit ?unit p:P2370 ?unitstmnode. # conversion to SI unit ?unitstmnode psv:P2370 ?unitvaluenode. ?unitvaluenode wikibase:quantityAmount ?conversion. ?unitvaluenode wikibase:quantityUnit wd:Q11573. # meter BIND(?length * ?conversion AS ?length_in_m).

SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". } } ORDER BY DESC(?length_in_m) LIMIT 10000

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title: rivers by length
SELECT ?item ?itemLabel  ?length_in_m ?length ?unitLabel ?lowerbound ?upperbound ?precision ?length2 ?conversion
WHERE
{
  ?item          wdt:P31/wdt:P279*           wd:Q47521.    # bach
  ?item          p:P2043                     ?stmnode.    # length
  ?stmnode       psv:P2043                   ?valuenode.
  ?valuenode     wikibase:quantityAmount     ?length.
  ?valuenode     wikibase:quantityUnit       ?unit.
  optional {?valuenode     wikibase:quantityLowerBound ?lowerbound.
  ?valuenode     wikibase:quantityUpperBound ?upperbound.
  BIND((?upperbound-?lowerbound)/2 AS ?precision).
  BIND(IF(?precision=0, ?length, (CONCAT(str(?length), "±", str(?precision)))) AS ?length2). }

  # conversion to SI unit
  ?unit          p:P2370                 ?unitstmnode.   # conversion to SI unit
  ?unitstmnode   psv:P2370               ?unitvaluenode. 
  ?unitvaluenode wikibase:quantityAmount ?conversion.
  ?unitvaluenode wikibase:quantityUnit   wd:Q11573.      # meter
  BIND(?length * ?conversion AS ?length_in_m).

  SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
} 
ORDER BY DESC(?length_in_m)
LIMIT 10000

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v13("?conversion"):::projected v2("?item"):::projected v5("?length"):::projected v10("?length2"):::projected v14("?length_in_m"):::projected v7("?lowerbound"):::projected v9("?precision"):::projected v3("?stmnode") v6("?unit") v11("?unitstmnode") v12("?unitvaluenode") v8("?upperbound"):::projected v4("?valuenode") a1((" ")) c3(["wd:Q47521"]):::iri c12(["wd:Q11573"]):::iri c14(["bd:serviceParam"]):::iri c16(["de,en"]):::literal v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 v2 --"p:P2043"--> v3 v3 --"p:statement/value/P2043"--> v4 v4 --"wikibase:quantityAmount"--> v5 v4 --"wikibase:quantityUnit"--> v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."wikibase:quantityLowerBound".-> v7 v4 --"wikibase:quantityUpperBound"--> v8 bind0[/"?upperbound - ?lowerbound / '2^^xsd:integer'"/] v8 --o bind0 v7 --o bind0 bind0 --as--o v9 bind1[/"if(?precision = '0^^xsd:integer',?length,concat(str(?length),'±',str(?precision)))"/] v9 --o bind1 v5 --o bind1 bind1 --as--o v10 end v6 --"p:P2370"--> v11 v11 --"p:statement/value/P2370"--> v12 v12 --"wikibase:quantityAmount"--> v13 v12 --"wikibase:quantityUnit"--> c12 bind2[/"?length * ?conversion"/] v5 --o bind2 v13 --o bind2 bind2 --as--o v14 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end