query-20fcdb3a33e6d89ae38cad9ba16705bc
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 )?count(DESC ORDER BY ?count ?itemLabel ?item GROUP BY } } . ?otherLabel label:rdfs ?other . ?itemLabel label:rdfs ?item ."[AUTO_LANGUAGE],en" language:wikibase serviceParam:bd { label:wikibase SERVICE } ?other P460:wdt ?item { OPTIONAL %surnames INCLUDE ."None" optimizer:hint Query:hint { WHERE %surnames as } ?item GROUP BY } ?item P734:wdt ; Q20:wd P27:wdt ?p { WHERE )?count as )?p DISTINCT(COUNT( ?item SELECT { WITH )?others as )", "=separator ;?otherLabel DISTINCT(GROUP_CONCAT( ?count ?itemLabel ?item SELECT 18:53, 20 September 2020 (UTC) Jura:. Maybe "?other" should be filtered for Norwegians as well, but I couldn't get that to work. --- Pmt @21:45, 20 September 2020 (UTC)) talk (Dipsacus fullonum in the query. The change makes the query to execute in nearly half time (22 seconds instead of 40 seconds for me). It will only give different results if somebody has the same name more than once, which never or almost never happens as far as know, so I don't think that is an issue. --COUNT(*) with COUNT(DISTINCT ?p): Try to replace Pmt, Jura1@ 20:33, 20 September 2020 (UTC)) talk (Pmt (P4574)Norwegian historical register of persons ID Very nice! It works, then next step would be to have a list only for persons having an ID in Histreg.no 19:50, 20 September 2020 (UTC) JuraTry with the hint I just added. If it times out, retry once or twice. It worked for me, but close to 60s . --- 19:40, 20 September 2020 (UTC)) talk (Pmt: Not so unexspected the query was timing out, could it be limited in some way, only men in one and women in another for instance? Jura1@
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?all ?names
WHERE
{
SELECT ?other (sum(?count) as ?all) (GROUP_CONCAT(DISTINCT CONCAT(?nl, " (",str(?count),"), ") ) as ?names)
{
{
SELECT ?other ?nl (COUNT(DISTINCT ?p ) as ?count)
WHERE
{
?p wdt:P27 wd:Q20 ; wdt:P21 wd:Q6581072 ; wdt:P734 ?item .
?item wdt:P1705 ?nl .
{ ?item wdt:P460* ?other } UNION { ?other wdt:P460* ?item } .
}
GROUP BY ?other ?nl
ORDER BY ?nl
}}
GROUP bY ?other
}
ORDER BY DESC(?all)
LIMIT 100