query-55d2a93114bf7ff3a0626c16f6d7ed29

rq turtle/ttl

NamesMost popular first names for MPs

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?nameLabel (count(distinct ?person1) as ?count)
WHERE {
 { ?person1 wdt:P31 wd:Q5 ; p:P39 ?ps . ?ps ps:P39 ?term .
   {?term wdt:P279* wd:Q16707842 } # UK MP
    UNION { ?term wdt:P279* wd:Q18015642 } # British MP
    UNION { ?term wdt:P279* wd:Q18018860 } # English MP
   }
 union { ?person1 wdt:P31 wd:Q5 ; wdt:P1614 ?hop } # or in HoP but without an item
 ?person1 wdt:P735 ?name
 SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?nameLabel
ORDER BY desc(?count)
#defaultView:BubbleChart

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?count") v5("?hop") v6("?name") v2("?person1"):::projected v3("?ps") v4("?term") c8(["wd:Q18018860"]):::iri c6(["wd:Q16707842"]):::iri c14(["en"]):::literal c12(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c7(["wd:Q18015642"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c2 v2 --"p:direct/P1614"--> v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c2 v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> v4 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; v4 --"p:direct/P279"--> c8 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P279"--> c7 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v4 --"p:direct/P279"--> c6 end union1r <== or ==> union1l end end union0r <== or ==> union0l end v2 --"p:direct/P735"--> v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end bind1[/"count(?person1)"/] v2 --o bind1 bind1 --as--o v7