query-954b79fd316241f5381e7ba3e6ca5466

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?startPro ?endPro ?startCity ?endCity WHERE {
  { ?item wdt:P131 wd:Q16287 . } UNION { ?item wdt:P131 wd:Q18288162 . }
  OPTIONAL { ?item p:P131 [ ps:P131 wd:Q16287 ; pq:P580 ?startPro ] . }
  OPTIONAL { ?item p:P131 [ ps:P131 wd:Q16287 ; pq:P582 ?endPro ] . }
  OPTIONAL { ?item p:P131 [ ps:P131 wd:Q18288162 ; pq:P580 ?startCity ] . }
  OPTIONAL { ?item p:P131 [ ps:P131 wd:Q18288162 ; pq:P582 ?endCity ] . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,it". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?endCity"):::projected v3("?endPro"):::projected v1("?item"):::projected v4("?startCity"):::projected v2("?startPro"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) c9(["bd:serviceParam"]):::iri c2(["wd:Q16287"]):::iri c3(["wd:Q18288162"]):::iri c11(["en,it"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P131"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P131"--> c2 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; a1 -."p:statement/P131".-> c2 a1 --"p:qualifier/P580"--> v2 v1 --"p:P131"--> a1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a2 -."p:statement/P131".-> c2 a2 --"p:qualifier/P582"--> v3 v1 --"p:P131"--> a2 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; a3 -."p:statement/P131".-> c3 a3 --"p:qualifier/P580"--> v4 v1 --"p:P131"--> a3 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; a4 -."p:statement/P131".-> c3 a4 --"p:qualifier/P582"--> v5 v1 --"p:P131"--> a4 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end