query-992f9143c7f7ae4c0ea1b955a756857a
It would be slightly simpler if you didn't ask for nationality, as that tends to be multi-valued, what would generate several lines for the same person with the below approach:
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?itemDescription ?genderLabel
WHERE
{
?item wdt:P1343 wd:Q46002746 ; wdt:P31 wd:Q5
OPTIONAL { ?item wdt:P21 ?gender }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
}
ORDER BY ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?gender")
v2("?item"):::projected
v1("?itemLabel"):::projected
c7(["bd:serviceParam"]):::iri
c2(["wd:Q46002746"]):::iri
c4(["wd:Q5"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"wdt:P1343"--> c2
v2 --"wdt:P31"--> c4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P21".-> v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end