query-c78b9b2e7a51226dfc46a4b5a24eb478

rq turtle/ttl

03:04, 9 September 2016 (UTC)) talk (SycedAny idea how to make this work? Thanks a lot! 05:57, 9 September 2016 (UTC)) talk (Edgars2007You have to put ?website in another SAMPLE in select part. Putting variable in group by would also prevent from getting error, but then only items, which has P856, would show up in results. --Cool, that fixed this field! Last problem: City labels don't show up anymore, see the empty string generated for ?cityLabel:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel (SAMPLE(?image) as ?image) (SAMPLE(?website) as ?website) (SAMPLE(?cityLabel) 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.}     # 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; v4("?city") v6("?cityLabel"):::projected v6("?image"):::projected v1("?item"):::projected v6("?website"):::projected a1((" ")) c8(["bd:serviceParam"]):::iri c2(["wd:Q64"]):::iri c10(["en"]):::literal c4(["wd:Q145"]):::iri v1 --"wdt:P131"--> c2 v1 --"wdt:P131"--> a1 a1 --"wdt:P17"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P18".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P856".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P131".-> v4 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind3[/"sample(?image)"/] v6 --o bind3 bind3 --as--o v6 bind4[/"sample(?website)"/] v6 --o bind4 bind4 --as--o v6 bind5[/"sample(?cityLabel)"/] v6 --o bind5 bind5 --as--o v6