query-a6abac1d73108eb83aa3632ad23ee80f
Sorting a GROUP_CONCATHow can I get the following to return the keywords in alphabetical order?
Use at
- https://query.wikidata.org/sparql
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 {
VALUES ?item {wd:Q1180981 wd:Q950970 wd:Q2543161}.
OPTIONAL {?item wdt:P31 ?k. ?k rdfs:label ?keywordlist. FILTER (LANG(?keywordlist) = "en")}
}
GROUP by ?item
ORDER BY ?keywordlist
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?item"):::projected
v3("?k")
v1("?keywordlist"):::projected
v4("?keywords")
bind0[/VALUES ?item/]
bind0-->v2
bind00(["wd:Q1180981"])
bind00 --> bind0
bind01(["wd:Q950970"])
bind01 --> bind0
bind02(["wd:Q2543161"])
bind02 --> bind0
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P31".-> v3
v3 --"rdfs:label"--> v1
end
bind2[/"?keywordlist"/]
v1 --o bind2
bind2 --as--o v4