query-16f6e54b0b3d23ea78aa22ed747ce14d

rq turtle/ttl

21:15, 8 September 2016 (UTC)) talk (Smalyshev (WMF)Downside is you can't choose which image shows up. --Unfortunately, this seems to prevent me from adding any other field to the SELECT. For instance, if I add ?website like below I get a "Bad aggregate" error: 02:41, 9 September 2016 (UTC)) talk (SycedGROUP BY solves the problem indeed! I don't mind which image shows up, any of the available images is fine. Thanks a lot :-)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?item ?website (SAMPLE(?image) as ?image) 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
} GROUP BY ?item

Query found at