query-d390201c9a2e038a2f4e68e769a789e3

rq turtle/ttl

Propertiesinstance of (P31)image (P18)Commons category (P373)Deutsche Bahn station code (P8671)connecting line (P81)crosses (P177)carries (P2505)linear reference (P6710)

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 bd: <http://www.bigdata.com/rdf#>
SELECT
  ?item
  ?itemLabel
  ?wdLabel ?ps
  (GROUP_CONCAT(DISTINCT ?classLabel; SEPARATOR = ", ") AS ?classLabels)
  ?km
  ?code
  ?image
  ?cat
WHERE
{
  ?wds ?ps wd:Q819045.

  VALUES ?ps { ps:P81 ps:P177 ps:P2505 }.
  ?wd wikibase:statementProperty ?ps.

  BIND( IRI(STRBEFORE(REPLACE(STR(?wds), "/entity/statement/", "/entity/"), "-")) AS ?item ).

  OPTIONAL { ?wds pq:P6710 ?km . }
  OPTIONAL { ?item wdt:P31 ?class. }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?item wdt:P373 ?cat. }
  OPTIONAL { ?item wdt:P8671 ?code. }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
GROUP BY ?item ?itemLabel ?wdLabel ?ps ?km ?code ?image ?cat 
ORDER BY ?km ?wdLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?cat"):::projected v7("?class") v11("?classLabel"):::projected v12("?classLabels") v10("?code"):::projected v8("?image"):::projected v6("?item"):::projected v1("?km"):::projected v5("?ps"):::projected v5("?wd") v2("?wdLabel"):::projected v3("?wds") c11(["de"]):::literal c1(["wd:Q819045"]):::iri c9(["bd:serviceParam"]):::iri v3 -->v5--> c1 bind0[/VALUES ?ps/] bind0-->v5 bind00(["ps:P81"]) bind00 --> bind0 bind01(["ps:P177"]) bind01 --> bind0 bind02(["ps:P2505"]) bind02 --> bind0 v5 --"wikibase:statementProperty"--> v5 bind1[/"substring-before(replace(str(?wds),'/entity/statement/','/entity/'),'-')"/] v3 --o bind1 bind1 --as--o v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."pq:P6710".-> v1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P31".-> v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P18".-> v8 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P373".-> v9 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P8671".-> v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind3[/"?classLabel"/] v11 --o bind3 bind3 --as--o v12