query-f903e9f81b4a31084c82049387a24e86

rq turtle/ttl

21:40, 26 August 2024 (UTC)) talk (InfrastrukturThis is definitely not portable to other query engines. The ordering from subqueries is not guaranteed to be preserved. It should say so somewhere in the specification but I don't feel like digging through it right now. But my real query has WITH and subqueries for speed and ease of configuration, and wrapping does not work for a nested query. So this does not

Use at

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#>
SELECT DISTINCT ?item (GROUP_CONCAT(DISTINCT ?keywordlist; SEPARATOR=", ") AS ?keywords)
WHERE {
  {
  SELECT DISTINCT ?item ?keywordlist 

  WITH {SELECT ?item ?keys WHERE {
    VALUES ?item {wd:Q1180981 wd:Q950970 wd:Q2543161}.
    VALUES ?keys {
      wdt:P31  # instance
    }
  }
  } AS %i
  WHERE {
    {INCLUDE %i}  
      {?item ?keys ?k. ?k rdfs:label ?keywordlist. FILTER (LANG(?keywordlist) = "en")}
  }
  ORDER BY ?item ?keywordlist
  }
}
GROUP BY ?item

Query found at