query-59bff00c101b3fa66db31d94c6bfd8e9
Last names for Norwegian citizens 18:37, 20 September 2020 (UTC)) talk (Pmt. Breg (P460)said to be the same as also have been (P734)family name and who having last names where the (Q20)Norway (P27)country of citizenship I want to have listed all last names for Norwegian having
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT
?item ?itemLabel ?count
(GROUP_CONCAT(DISTINCT ?otherLabel; separator=", ") as ?others)
WHERE
{
{
SELECT ?item (COUNT(DISTINCT ?p) as ?count) WHERE { ?p wdt:P27 wd:Q20 ; wdt:P734 ?item } GROUP BY ?item
} OPTIONAL { ?item wdt:P460 ?other }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?item rdfs:label ?itemLabel .
?other rdfs:label ?otherLabel .
}
}
GROUP BY ?item ?itemLabel ?count
ORDER BY DESC(?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?count"):::projected
v3("?item"):::projected
v5("?itemLabel"):::projected
v4("?other")
v6("?otherLabel"):::projected
v7("?others")
v2("?p")
c6(["bd:serviceParam"]):::iri
c2(["wd:Q20"]):::iri
c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"wdt:P27"--> c2
v2 --"wdt:P734"--> v3
bind1[/"count(?p)"/]
v2 --o bind1
bind1 --as--o v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P460".-> v4
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
v3 --"rdfs:label"--> v5
v4 --"rdfs:label"--> v6
end
bind3[/"?otherLabel"/]
v6 --o bind3
bind3 --as--o v7