query-779f45bbfed124e713f7a8a56e5fccde
Removing duplicate pairsHi, is symmetric, all resultat are duplicated : « stationX, stationY » and then « stationY, stationX »). (P197)adjacent station I stumble upon a duplication problem I don't know how to solve. How can I remove the duplicate pairs in the following request? (as
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?stationA ?stationALabel ?stationB ?stationBLabel ?slope ?altA ?altB ?coordA ?coordB ?diff ?dist
WHERE
{
?stationA wdt:P197 ?stationB .
?stationA wdt:P2044 ?altA ; wdt:P625 ?coordA .
?stationB wdt:P2044 ?altB ; wdt:P625 ?coordB .
BIND( geof:distance( ?coordA , ?coordB) as ?dist ) .
BIND( abs(?altA - ?altB) as ?diff )
BIND( (?diff / ?dist) as ?slope )
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
} order by desc(?slope)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?altA"):::projected
v6("?altB"):::projected
v5("?coordA"):::projected
v7("?coordB"):::projected
v9("?diff"):::projected
v8("?dist"):::projected
v10("?slope"):::projected
v2("?stationA"):::projected
v3("?stationB"):::projected
c5(["bd:serviceParam"]):::iri
c7(["fr,en"]):::literal
v2 --"wdt:P197"--> v3
v2 --"wdt:P2044"--> v4
v2 --"wdt:P625"--> v5
v3 --"wdt:P2044"--> v6
v3 --"wdt:P625"--> v7
bind0[/"http://www.opengis.net/def/function/geosparql/distance(?coordA,?coordB)"/]
v5 --o bind0
v7 --o bind0
bind0 --as--o v8
bind1[/"numeric-abs(?altA - ?altB)"/]
v4 --o bind1
v6 --o bind1
bind1 --as--o v9
bind2[/"?diff / ?dist"/]
v9 --o bind2
v8 --o bind2
bind2 --as--o v10
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end