query-fedfacb362a9a869f8321723e34b1581
with one of the two properties and all other labels in a specific language (here English): (Q16334295)group of humans List of all
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#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?group ?selfidentified ?nonselfidentified (GROUP_CONCAT(DISTINCT ?label; SEPARATOR=", ") AS ?labels) WHERE {
# set language
BIND('en' AS ?lang)
# ?group instance/subclass of group of humans
?group wdt:P31/wdt:P279* wd:Q16334295.
# find groups with either self-identified or non-self-identified names
{
# self-indentified name
?group wdt:P12089 ?temp.
} UNION {
# non-self-indentified name
?group wdt:P12090 ?temp.
}
FILTER(lang(?temp)=?lang)
# find the names again
OPTIONAL {
# self-indentified name
?group wdt:P12089 ?selfidentified.
FILTER(lang(?selfidentified)=?lang)
}
OPTIONAL {
# non-self-indentified name
?group wdt:P12090 ?nonselfidentified.
FILTER(lang(?selfidentified)=?lang)
}
# find labels
{
?group rdfs:label ?label .
} UNION {
?group skos:altLabel ?label .
}
FILTER(lang(?label)=?lang)
} GROUP BY ?group ?selfidentified ?nonselfidentified
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?group"):::projected
v1("?label"):::projected
v7("?labels")
v5("?lang")
v6("?nonselfidentified"):::projected
v3("?selfidentified"):::projected
v4("?temp")
a1((" "))
c3(["wd:Q16334295"]):::iri
f0[["?label = ?lang"]]
f0 --> v1
f0 --> v5
f1[["?temp = ?lang"]]
f1 --> v4
f1 --> v5
bind2[/"'en'"/]
bind2 --as--o v5
v5 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v5 --"wdt:P12090"--> v4
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v5 --"wdt:P12089"--> v4
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wdt:P12089".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wdt:P12090".-> v6
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v5 --"skos:altLabel"--> v1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v5 --"rdfs:label"--> v1
end
union1r <== or ==> union1l
end
bind4[/"?label"/]
v1 --o bind4
bind4 --as--o v7