query-86167258e0f46a54d1fae4a61dddc2b6
ordering within a GROUP_CONCATIn this query (a stripped down version of a more complicated system where many queries are done and aggregated using sort -u)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?itemDescription ?images WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
{
SELECT DISTINCT ?item
(REPLACE(GROUP_CONCAT(DISTINCT ?imagelist; SEPARATOR = ","),"http://commons.wikimedia.org/wiki/Special:FilePath/","") AS ?images)
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
?item p:P31 ?statement0.
?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
?item wdt:P17 wd:Q145.
OPTIONAL {?item wdt:P18 ?imagelist}
}
GROUP BY ?item
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?_anon_42b5416610844a34809f33a099ae9de181066")
v3("?imagelist")
v5("?images"):::projected
v1("?item"):::projected
v2("?statement0")
a1((" "))
c2(["bd:serviceParam"]):::iri
c4(["en-GB,en"]):::literal
c8(["wd:Q1785071"]):::iri
c10(["wd:Q145"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v1 --"p:P31"--> v2
v2 --"p:statement/P31"--> a1
a1 --"p:direct/P279"--> c8
v1 --"p:direct/P17"--> c10
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P18".-> v3
end
bind1[/"?imagelist"/]
v3 --o bind1
bind1 --as--o v4
bind2[/"replace(,'http://commons.wikimedia.org/wiki/Special:FilePath/','')"/]
null --o bind2
bind2 --as--o v5