query-16992b56782411dbb7da7abd96eed61e

rq turtle/ttl

People with multiple MPs as children SELECT distinct ?person ?personLabel ?born ?died ?count WHERE { { select distinct ?person (count(distinct ?child) as ?count) where { ?person wdt:P40 ?child . ?child p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . { ?term wdt:P279 wd:Q16707842 } union { ?term wdt:P279 wd:Q18015642 } union { ?term wdt:P279 wd:Q18018860 } } group by ?person } optional { ?person wdt:P569 ?born } optional { ?person wdt:P570 ?died } filter (?count > 3 ) . SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } order by desc(?count)

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#>
# People with multiple MPs as children
SELECT distinct ?person ?personLabel ?born ?died ?count WHERE {
  { select distinct ?person (count(distinct ?child) as ?count) where {
  ?person wdt:P40 ?child . 
  ?child p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . 
  { ?term wdt:P279 wd:Q16707842 } union { ?term wdt:P279 wd:Q18015642 } union { ?term wdt:P279 wd:Q18018860 } 
  } group by ?person } 
  optional { ?person wdt:P569 ?born }
  optional { ?person wdt:P570 ?died }
  filter (?count > 3 ) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } 
} order by desc(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?born"):::projected v3("?child") v6("?count"):::projected v7("?died"):::projected v2("?person"):::projected v4("?positionStatement") v5("?term") c8(["wd:Q18018860"]):::iri c6(["wd:Q16707842"]):::iri c14(["en"]):::literal c12(["bd:serviceParam"]):::iri c7(["wd:Q18015642"]):::iri f0[["?count > '3^^xsd:integer'"]] f0 --> v6 v2 --"p:direct/P40"--> v3 v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> v5 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P279"--> c8 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P279"--> c7 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P279"--> c6 end union0r <== or ==> union0l end bind2[/"count(?child)"/] v3 --o bind2 bind2 --as--o v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P569".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P570".-> v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end