query-e2374ffc2b8be4cda7028a6d99c54cd8
Single image of each person in query results – examples below, so that only one image of each person appears in the results. Wikidata:WikiProject The Women’s Library LSESuffrageInterviewsProjectI’m trying to modify some image grids for https://w.wiki/9DoB or https://w.wiki/9DoL I’ve been working with (SAMPLE(?image) as ?image) and various longer adjustments, but keep getting malformed query errors. 11:50, 20 February 2024 (UTC)) talk (HelsKRWAny expertise would be appreciated! Many thanks : For the second of these, the issue is that the two variable names in (SAMPLE(?image_) AS ?image) must be different; (SAMPLE(?image) AS ?image) does not work:HelsKRW@
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#>
#defaultView:ImageGrid
SELECT DISTINCT ?person ?personLabel ?personDescription ?familynameLabel ?givennameLabel (SAMPLE(?image_) AS ?image) WHERE {
?person wdt:P5008 wd:Q117322976;
wdt:P31 wd:Q5;
wdt:P9600 wd:Q2371017.
OPTIONAL { ?person wdt:P734 ?familyname. }
OPTIONAL { ?person wdt:P735 ?givenname. }
OPTIONAL { ?person wdt:P18 ?image_. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?person ?personLabel ?personDescription ?familynameLabel ?givennameLabel
ORDER BY (?familynameLabel)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?familyname")
v1("?familynameLabel"):::projected
v4("?givenname")
v6("?image")
v5("?image_"):::projected
v2("?person"):::projected
c6(["wd:Q2371017"]):::iri
c11(["bd:serviceParam"]):::iri
c2(["wd:Q117322976"]):::iri
c4(["wd:Q5"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"wdt:P5008"--> c2
v2 --"wdt:P31"--> c4
v2 --"wdt:P9600"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P734".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P735".-> v4
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P18".-> v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
bind1[/"sample(?image_)"/]
v5 --o bind1
bind1 --as--o v6