query-37616e58513e36ef23a80b7644412ae4
Greatest number of horizontaly and verticaly juniorsHello everyone ! I want to find the humans with the more descendants having the same given name than them, horizontaly (example : a father named Joseph who name all his sons Joseph) and verticaly (example : William, 15th of name). I have this, but it is obviously too simple :
Use at
- https://query.wikidata.org/sparql
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?generation (COUNT(?descendant) AS ?count)
WHERE {
?person wdt:P31 wd:Q5; # ĂȘtre un humain
wdt:P40 ?descendant.
?descendant wdt:P40 ?generation.
?person rdfs:label ?personLabel.
?descendant rdfs:label ?descendantLabel.
FILTER (?personLabel != ?descendantLabel)
}
GROUP BY ?generation
ORDER BY DESC(?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?count")
v5("?descendant"):::projected
v3("?descendantLabel")
v6("?generation"):::projected
v4("?person")
v2("?personLabel")
c2(["wd:Q5"]):::iri
f0[["?personLabel != ?descendantLabel"]]
f0 --> v2
f0 --> v3
v4 --"wdt:P31"--> c2
v4 --"wdt:P40"--> v5
v5 --"wdt:P40"--> v6
v4 --"rdfs:label"--> v2
v5 --"rdfs:label"--> v3
bind2[/"count(?descendant)"/]
v5 --o bind2
bind2 --as--o v7