query-21e101695b585c3a71a0f915bc865da7

rq turtle/ttl

06:23, 9 September 2016 (UTC)) talk (Syced but not sure whether it is the way to go... Thank you! hereAny idea how to correctly select itemLabel and cityLabel? I have spotted "rdfs:label" usage

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel (SAMPLE(?image) as ?image) (SAMPLE(?website) as ?website) (SAMPLE(?city_label) as ?cityLabel) WHERE {
  ?item wdt:P131 wd:Q64.               # operated by the UK
  ?item wdt:P131*/wdt:P17 wd:Q145.     # in Germany
  OPTIONAL {?item wdt:P18 ?image.}     # get an image if there is one
  OPTIONAL {?item wdt:P856 ?website.}  # get the website if there is one
  OPTIONAL {?item wdt:P131 ?city.
            ?city rdfs:label ?city_label .
             filter (lang(?city_label) = "en") .
           }     # get the city if there is one
  SERVICE wikibase:label {bd:serviceParam wikibase:language "en"}
} GROUP BY ?item ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?city") v6("?cityLabel") v1("?city_label"):::projected v6("?image"):::projected v2("?item"):::projected v6("?website"):::projected a1((" ")) c10(["bd:serviceParam"]):::iri c3(["wd:Q64"]):::iri c1(["en"]):::literal c5(["wd:Q145"]):::iri v2 --"wdt:P131"--> c3 v2 --"wdt:P131"--> a1 a1 --"wdt:P17"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P18".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P856".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P131".-> v5 v5 --"rdfs:label"--> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c1 end bind3[/"sample(?image)"/] v6 --o bind3 bind3 --as--o v6 bind4[/"sample(?website)"/] v6 --o bind4 bind4 --as--o v6 bind5[/"sample(?city_label)"/] v1 --o bind5 bind5 --as--o v6