query-91f94f3cd05eebd2c5fe009a56765ea5

rq turtle/ttl

Propertiesinstance of (P31)sex or gender (P21)place of birth (P19)located in the administrative territorial entity (P131)date of birth (P569)date of death (P570)place of death (P20)

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?statements (COUNT(distinct ?sitelink) as ?sites) ?itemLabel ?birth ?pobLabel ?death ?podLabel
WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }   # for generating label
BIND(xsd:integer(STRAFTER(str(?item), "Q")) AS ?qid) .   ?item wikibase:statements ?statements . # for counting statements
OPTIONAL { ?sitelink schema:about ?item . ?sitelink schema:inLanguage ?lang } # for counting sitelinks
    ?item wdt:P31 wd:Q5 .   # item = humans only
    ?item wdt:P21 wd:Q6581072 .       # gender = female only
    { ?item wdt:P19 wd:Q664 }       # place of birth = New Zealand (Q664) 
        UNION  { ?item wdt:P19 ?pob . ?pob wdt:P131* wd:Q664 }  # OR place of birth within New Zealand. 
                    OPTIONAL { ?item wdt:P569 ?birth  }
                    OPTIONAL { ?item wdt:P19 ?pob  }
                    OPTIONAL { ?item wdt:P570 ?death  }
                    OPTIONAL { ?item wdt:P20 ?pod  }
    }
GROUP BY ?item ?statements ?itemLabel ?birth ?pobLabel ?death ?podLabel
ORDER BY DESC(?sites)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?birth"):::projected v9("?death"):::projected v3("?item"):::projected v6("?lang") v7("?pob") v10("?pod") v2("?qid") v5("?sitelink"):::projected v11("?sites") v4("?statements"):::projected c11(["wd:Q6581072"]):::iri c13(["wd:Q664"]):::iri c2(["bd:serviceParam"]):::iri c9(["wd:Q5"]):::iri c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end bind0[/"http://www.w3.org/2001/XMLSchema#integer(substring-after(str(?item),'Q'))"/] v3 --o bind0 bind0 --as--o v2 v3 --"wikibase:statements"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."schema:about".-> v3 v5 --"schema:inLanguage"--> v6 end v3 --"wdt:P31"--> c9 v3 --"wdt:P21"--> c11 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P19"--> v7 v7 --"wdt:P131"--> c13 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P19"--> c13 end union0r <== or ==> union0l end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P569".-> v8 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P19".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P570".-> v9 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P20".-> v10 end bind2[/"count(?sitelink)"/] v5 --o bind2 bind2 --as--o v11