query-4dca7ead539f475ebce54f989397dc10
DISTINCT for character stringsFor
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?item
(GROUP_CONCAT(DISTINCT ?namelist; SEPARATOR = ", ") AS ?names)
(COUNT (DISTINCT ?namelist) AS ?count) WHERE {
VALUES ?item {wd:Q2420611}
OPTIONAL
{
{?item wdt:P2561 ?namelist} # name
UNION {?item wdt:P1448 ?namelist} # official name
UNION {?item wdt:P1449 ?namelist} # nickname
UNION {?item wdt:P879 ?namelist} # pennant
UNION {?item skos:altLabel ?namelist. FILTER(LANG(?namelist) = "en")} # aliases
}
}
GROUP BY ?item
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?count")
v1("?item"):::projected
v2("?namelist"):::projected
v3("?names")
bind0[/VALUES ?item/]
bind0-->v1
bind00(["wd:Q2420611"])
bind00 --> bind0
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
f1[["?namelist = 'en'"]]
f1 --> v2
v1 -."skos:altLabel".-> v2
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P879"--> v2
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P1449"--> v2
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P1448"--> v2
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P2561"--> v2
end
union0r <== or ==> union0l
end
end
bind4[/"?namelist"/]
v2 --o bind4
bind4 --as--o v3
bind5[/"count(?namelist)"/]
v2 --o bind5
bind5 --as--o v4